Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sends a batch of messages to a Service Bus queue or topic.
Request
| Method | Request URI | HTTP Version |
|---|---|---|
| POST | https://{serviceNamespace}.servicebus.windows.net/{queuePath|topicPath}/messages |
HTTP/1.1 |
Request Headers
The following table describes required and optional request headers. Custom headers on this request aren't applied to the messages in the batch. To set custom properties on a message in a batch, use the UserProperties object for that message in the request body. See the example.
| Request Header | Description |
|---|---|
| Authorization | Specify one of the following token values:
|
Content-Type |
Set to application/vnd.microsoft.servicebus.json, without parameters such as charset=utf-8. |
| x-ms-retrypolicy | (Optional) Set to NoRetry to disable automatic retry on send operations in the case of transient errors. |
Request Body
The request body is a JSON array of messages. Each message contains a Body string and can include BrokerProperties and UserProperties objects. Set IsBodyBase64 to true for a base64-encoded binary body; otherwise, Body is encoded as UTF-8 text.
Important
Use the exact batch media type application/vnd.microsoft.servicebus.json. On a Standard namespace, appending ; charset=utf-8 causes the JSON array to be sent as one message instead of a batch.
Response
The response includes an HTTP status code and a set of response headers.
Response Codes
| Code | Description |
|---|---|
| 201 | Message successfully sent to queue or topic. |
| 400 | Bad request. |
| 401 | Authorization failure. |
| 403 | Quota exceeded or message too large. |
| 410 | Specified queue or topic doesn't exist. |
| 500 | Internal error. |
For information about status codes, see Status and Error Codes.
Response Headers
| Response Header | Description |
|---|---|
Content-Type |
application/xml; charset=utf-8 for a successful send. The response body is empty. |
Response Body
None.
Example
The following HTTP request sends a batch of three messages to a queue or topic. The first message has a TimeToLiveTimeSpan value of 40 seconds, the second message has a custom message property Priority, and the third message has the custom message properties Priority and Customer.
POST https://your-namespace.servicebus.windows.net/HttpClientSampleQueue/messages?timeout=60 HTTP/1.1
Authorization: SharedAccessSignature sr=your-namespace&sig=Fg8yUyR4MOmXfHfj55f5hY4jGb8x2Yc%2b3%2fULKZYxKZk%3d&se=1404256819&skn=RootManageSharedAccessKey
Content-Type: application/vnd.microsoft.servicebus.json
Host: your-namespace.servicebus.windows.net
Content-Length: 341
Expect: 100-continue
[{"Body":"This is the first message","BrokerProperties":{"Label":"M1","TimeToLiveTimeSpan":"0.00:00:40"}},{"Body":"This is the second message","BrokerProperties":{"Label":"M2"},"UserProperties":{"Priority":"Low"}},{"Body":"This is the third message","BrokerProperties":{"Label":"M3"},"UserProperties":{"Priority":"Medium","Customer":"ABC"}}]
Service Bus returns the following response:
HTTP/1.1 201 Created
Transfer-Encoding: chunked
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 01 Jul 2014 23:00:22 GMT
0