Application Octet Stream Download
Various content types can flow through a logic app,for example, JSON, XML, flat files, and binary data.While Logic Apps supports all content types, some have nativesupport and don't require casting or conversion in your logic apps.Other types might require casting or conversion as necessary.This article describes how Logic Apps handles content types andhow you can correctly cast or convert these types when necessary.
To determine the appropriate way for handling content types,Logic Apps relies on the Content-Type
header value in HTTP calls,for example:
- application/json (native type)
- text/plain (native type)
application/json
Logic Apps stores and handles any request with the application/jsoncontent type as a JavaScript Notation (JSON) object.By default, you can parse JSON content without any casting.To parse a request that has a header with the 'application/json' content type,you can use an expression. This example returns the value dog
from theanimal-type
array without casting:
@body('myAction')['animal-type'][0]
If you're working with JSON data that doesn't specify a header,you can manually cast that data to JSON by using thejson() function,for example:
@json(triggerBody())['animal-type']
Create tokens for JSON properties
Logic Apps provides the capability for you to generate user-friendlytokens that represent the properties in JSON content so you canreference and use those properties more easily in your logic app's workflow.
Request trigger
When you use this trigger in the Logic App Designer, you can providea JSON schema that describes the payload you expect to receive.The designer parses JSON content by using this schema and generatesuser-friendly tokens that represent the properties in your JSON content.You can then easily reference and use those properties throughout yourlogic app's workflow.
If you don't have a schema, you can generate the schema.
In the Request trigger, select Use sample payload to generate schema.
Under Enter or paste a sample JSON payload, provide a sample payloadand then choose Done. For example:
The generated schema now appears in your trigger.
Here is the underlying definition for your Request trigger in the code view editor:
In your request, make sure you include a
Content-Type
headerand set the header's value toapplication/json
.
Parse JSON action
When you use this action in the Logic App Designer,you can parse JSON output and generate user-friendlytokens that represent the properties in your JSON content.You can then easily reference and use those propertiesthroughout your logic app's workflow. Similar tothe Request trigger, you can provide or generate aJSON schema that describes the JSON content you want to parse.That way, you can more easily consume data from Azure Service Bus,Azure Cosmos DB, and so on.
text/plain
When your logic app receives HTTP messages thathave the Content-Type
header set to text/plain
,your logic app stores those messages in raw form.If you include these messages in subsequent actions without casting,requests go out with the Content-Type
header set to text/plain
.
For example, when you're working with a flat file,you might get an HTTP request with the Content-Type
header set to text/plain
content type:
Date,Name,Address
Oct-1,Frank,123 Ave
If you then send this request on in a later action as the body for another request,for example, @body('flatfile')
, that second request also has a Content-Type
header that's set to text/plain
. If you're working with data that is plain textbut didn't specify a header, you can manually cast that data to text by using thestring() functionsuch as this expression:
@string(triggerBody())
application/xml and application/octet-stream
Logic Apps always preserves the Content-Type
in a received HTTP request or response.So if your logic app receives content with Content-Type
set to application/octet-stream
,and you include that content in a later action without casting,the outgoing request also has Content-Type
set to application/octet-stream
.That way, Logic Apps can guarantee that data doesn't get lost while moving through the workflow.However, the action state, or inputs and outputs, is stored in a JSON objectwhile the state moves through the workflow.
Converter functions
To preserve some data types, Logic Apps converts content to a binarybase64-encoded string with appropriate metadata that preserves boththe $content
payload and the $content-type
, which are automatically converted.
This list describes how Logic Apps converts content when you use thesefunctions:
json()
: Casts data toapplication/json
xml()
: Casts data toapplication/xml
binary()
: Casts data toapplication/octet-stream
string()
: Casts data totext/plain
base64()
: Converts content to a base64 stringbase64toString()
: Converts a base64 encoded string totext/plain
base64toBinary()
: Converts a base64 encoded string toapplication/octet-stream
encodeDataUri()
: Encodes a string as a dataUri byte arraydecodeDataUri()
: Decodes adataUri
into a byte array
For example, if you receive an HTTP requestwhere Content-Type
set to application/xml
,such as this content:
You can cast this content by using the @xml(triggerBody())
expression with the xml()
and triggerBody()
functionsand then use this content later. Or, you can use the@xpath(xml(triggerBody()), '/CustomerName')
expressionwith the xpath()
and xml()
functions.
Other content types
Logic Apps works with and supports other content types,but might require that you manually get the messagebody by decoding the $content
variable.
For example, suppose your logic app gets triggered by a requestwith the application/x-www-url-formencoded
content type.To preserve all the data, the $content
variable in therequest body has a payload that's encoded as a base64 string:
CustomerName=Frank&Address=123+Avenue
Because the request isn't plain text or JSON,the request is stored in the action as follows:
Logic Apps provides native functions for handling form data, for example:
Or, you can manually access the data by using an expression such as this example:
@string(body('formdataAction'))
If you wanted the outgoing request to have the sameapplication/x-www-url-formencoded
content type header,you can add the request to the action's body withoutany casting by using an expression such as @body('formdataAction')
.However, this method only works when the body is the onlyparameter in the body
input. If you try to use the@body('formdataAction')
expression in an application/json
request,you get a runtime error because the body is sent encoded.
MIME Content Type: application
What is MIME Application/Octet-stream?
The MIME type application/Octet-stream is considered to be one of the popular multipurpose application files. Generally this type is used for identifying the data that is not associated with any specific application. An Application/Octet-stream is a MIME attachment which is present in the operating system. This MIME type is basically related to the file extension .bin as it relates to all of the binary files. It is one of the important types in the operating system. Application/Octet-stream comes in the category of binary files. The format will be according to the coding. The working of Application/Octet-stream can be seen in web browser. So the coding will be according to the working of the web browser. Every web browser is different and gives the user various operations for use of internet. The coded information is identified by the web browser and it gives the user various options to access the MIME type.
Different applications are loaded on the system. The working of Application/Octet-stream is to identify the file which is present in the email and then scan the system. The type scans the system for suitable application that can open the data which is received in the email. To see the operation of Application/Octet-stream an example can be given. If any important letter is sent through an email the working of Application/Octet-stream can be seen in the web browser. As the data is approached and clicked for viewing, the type will scan the system for appropriate applications and give the user available options. The preferred option in this case would be of word applications as the type is a letter. If there is an extension along it's easy for the system to identify it and use it. But in some cases there is no extension given. In such situations it is the use of Application/Octet-stream types that can help.
The working of Application/Octet-stream types is done in Windows and Macintosh operating systems only. The working can be seen according to the different set ups of the type. Every application is designed in a different manner. The coding of MIME type is also done accordingly. As the data is received through email this type of MIME is used. It caters the requirements of human in sending and receiving of data through online resources. With the help of this MIME type transfer of data takes place in less time on the net. Lots of web browsers uses application/Octet-stream.
How to fix MIME Application/Octet-stream errors?
Web browsers, like IE and Firefox, use MIME Types to determine the best host applications to render and present binary data sets that are embedded in web pages. When you encounter a MIME Application/Octet-stream error, it is caused by one of the following two types of errors:
1) You PC doesn't have a host application that can open and render MIME Application/Octet-stream content. Like file extensions, each MIME Type corresponds to a particular host application that can be used to read and write binary data sets according to the matching MIME Type specification.
2) Your PC may have errors in the Windows Registry due to corrupt and invalid entries. Even if you have a matching host application installed, it couldn't be found and used by the Internet browser.
Recommendation:
It is strongly recommended that you scan your PC to identify and correct these errors to properly view content embedded in MIME Application/Octet-stream format.