Skip to content

Commit 3a2f15d

Browse files
Apply suggestions from code review
Co-authored-by: Esther Fan <[email protected]>
1 parent cb9ff8c commit 3a2f15d

1 file changed

Lines changed: 37 additions & 30 deletions

File tree

articles/logic-apps/logic-apps-content-type.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,58 +134,65 @@ The following list describes common workflow operations and the corresponding wa
134134

135135
## text/plain
136136

137-
When your logic app receives HTTP messages that have 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`.
137+
If your workflow receives HTTP requests where the `Content-Type` header value is *text/plain*. Azure Logic Apps stores and handles the content in raw form. If you reference or use this content in subsequent workflow actions without casting or conversion, outbound requests also have the `Content-Type` header value set to `text/plain`.
138138

139-
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:
139+
For example, suppose you're working with a flat file, and the inbound HTTP request has the `Content-Type` header value set to `text/plain`:
140140

141141
`Date,Name,Address`</br>
142142
`Oct-1,Frank,123 Ave`
143143

144-
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 text but didn't specify a header, you can manually cast that data to text by using the [string() function](../logic-apps/workflow-definition-language-functions-reference.md#string) such as this expression:
144+
If you send this request to a subsequent action that uses the request body to send another request, the second request also has the `Content-Type` header value set to `text/plain`. If you work with data in plain text but didn't specify a header, you can manually cast this data to text by using the [`string()` function](workflow-definition-language-functions-reference.md#string), for example:
145145

146-
`@string(triggerBody())`
146+
`string(triggerBody())`
147147

148148
<a name="application-xml-octet-stream"></a>
149149

150150
## application/xml and application/octet-stream
151151

152-
Logic Apps always preserves the `Content-Type` in a received HTTP request or response. 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 be sure that data doesn't get lost while moving through the workflow. The action state, or inputs and outputs, is stored in a JSON object while the state moves through the workflow.
152+
Azure Logic Apps always preserves the `Content-Type` header value in an inbound HTTP request or response. If your workflow receives content with `Content-Type` set to *application/octet-stream*, and you include that content in a subsequent action without casting, the outbound request also sets `Content-Type` to `application/octet-stream`. This approach makes sure that data doesn't get lost while moving through the workflow. In stateful workflows, the subsequent action's state, inputs, and outputs are stored in a JSON object while the state moves through the workflow.
153153

154154
## Converter functions
155155

156-
To preserve some data types, Logic Apps converts content to a binary base64-encoded string with appropriate metadata that preserves both the `$content` payload and the `$content-type`, which are automatically converted.
156+
To preserve some data types, Azure Logic Apps converts content to a binary base64-encoded string. This string has the appropriate metadata that preserves both the `$content` payload and the `$content-type`, which are automatically converted.
157157

158-
This list describes how Logic Apps converts content when you use these [functions](../logic-apps/workflow-definition-language-functions-reference.md):
158+
The following list describes how Azure Logic Apps converts content when you use specific [functions](workflow-definition-language-functions-reference.md):
159159

160-
- `json()`: Casts data to `application/json`
161-
- `xml()`: Casts data to `application/xml`
162-
- `binary()`: Casts data to `application/octet-stream`
163-
- `string()`: Casts data to `text/plain`
164-
- `base64()`: Converts content to a base64-encoded string
165-
- `base64toString()`: Converts a base64-encoded string to `text/plain`
166-
- `base64toBinary()`: Converts a base64-encoded string to `application/octet-stream`
167-
- `dataUri()`: Converts a string to a data URI
168-
- `dataUriToBinary()`: Converts a data URI to a binary string
169-
- `dataUriToString()`: Converts a data URI to a string
160+
- `json()`: Casts data to `application/json`.
161+
- `xml()`: Casts data to `application/xml`.
162+
- `binary()`: Casts data to `application/octet-stream`.
163+
- `string()`: Casts data to `text/plain`.
164+
- `base64()`: Converts content to a base64-encoded string.
165+
- `base64toString()`: Converts a base64-encoded string to `text/plain`.
166+
- `base64toBinary()`: Converts a base64-encoded string to `application/octet-stream`.
167+
- `dataUri()`: Converts a string to a data URI.
168+
- `dataUriToBinary()`: Converts a data URI to a binary string.
169+
- `dataUriToString()`: Converts a data URI to a string.
170170

171-
For example, if you receive an HTTP request where `Content-Type` set to `application/xml`, such as this content:
171+
For example, suppose your workflow trigger receives an HTTP request where `Content-Type` set to `application/xml` where the content looks like the following sample:
172172

173173
```xml
174174
<?xml version="1.0" encoding="UTF-8" ?>
175175
<CustomerName>Frank</CustomerName>
176176
```
177177

178-
You can cast this content by using the `@xml(triggerBody())` expression with the `xml()` and `triggerBody()` functions and then use this content later. Or, you can use the `@xpath(xml(triggerBody()), '/CustomerName')` expression with the `xpath()` and `xml()` functions.
178+
You can cast this content by using the following expression, which uses the `xml()` and `triggerBody()` functions:
179+
180+
`xml(triggerBody())`
181+
182+
You can then use the resulting content with subsequent actions in the workflow. Or, you might use the following expression that uses the `xpath()` and `xml()` functions instead:
183+
184+
`xpath(xml(triggerBody()), '/CustomerName')`
185+
179186

180187
## Other content types
181188

182-
Logic Apps works with and supports other content types, but might require that you manually get the message body by decoding the `$content` variable.
189+
Azure Logic Apps supports other content types but might require that you manually get the message body from an HTTP request by decoding the `$content` variable.
183190

184-
For example, suppose your logic app gets triggered by a request with the `application/x-www-url-formencoded` content type. To preserve all the data, the `$content` variable in the request body has a payload that's encoded as a base64 string:
191+
For example, suppose your workflow receives an HTTP request where `Content-Type` is set to `application/x-www-url-formencoded`. To preserve all the data, the request body includes the `$content` variable where the payload is encoded as a base64 string:
185192

186193
`CustomerName=Frank&Address=123+Avenue`
187194

188-
Because the request isn't plain text or JSON, the request is stored in the action as follows:
195+
This content type isn't in plain text or JSON format, so Azure Logic Apps stores `CustomerName=Frank&Address=123+Avenue` using the following `$content-type` and `$content` variables:
189196

190197
```json
191198
"body": {
@@ -194,15 +201,15 @@ Because the request isn't plain text or JSON, the request is stored in the actio
194201
}
195202
```
196203

197-
Logic Apps provides native functions for handling form data, for example:
204+
Azure Logic Apps also includes native functions to handle form data, for example:
198205

199-
- [triggerFormDataValue()](../logic-apps/workflow-definition-language-functions-reference.md#triggerFormDataValue)
200-
- [triggerFormDataMultiValues()](../logic-apps/workflow-definition-language-functions-reference.md#triggerFormDataMultiValues)
201-
- [formDataValue()](../logic-apps/workflow-definition-language-functions-reference.md#formDataValue)
202-
- [formDataMultiValues()](../logic-apps/workflow-definition-language-functions-reference.md#formDataMultiValues)
206+
- [triggerFormDataValue()](workflow-definition-language-functions-reference.md#triggerFormDataValue)
207+
- [triggerFormDataMultiValues()](workflow-definition-language-functions-reference.md#triggerFormDataMultiValues)
208+
- [formDataValue()](workflow-definition-language-functions-reference.md#formDataValue)
209+
- [formDataMultiValues()](workflow-definition-language-functions-reference.md#formDataMultiValues)
203210

204-
Or, you can manually access the data by using an expression such as this example:
211+
Or, you can manually access the data by using an expression such as the following example:
205212

206-
`@string(body('formdataAction'))`
213+
`string(body('formdataAction'))`
207214

208-
If you wanted the outgoing request to have the same `application/x-www-url-formencoded` content type header, you can add the request to the action's body without any casting by using an expression such as `@body('formdataAction')`. This method only works when the body is the only parameter 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.
215+
To make an outbound request use `application/x-www-url-formencoded` as the `Content-Type` header value, add the request content to the action body without any casting by using an expression such as `body('formdataAction')`. This method works only if the action body is the only parameter in the `body` inputs object. If you use the `body('formdataAction')` expression in a request where the content type is `application/json`, you get a runtime error because the body is sent encoded.

0 commit comments

Comments
 (0)