Hello,
I am sending batch topic to Azure by using REST API but getting error.
Http http = new Http();
HttpRequest request = new HttpRequest(); request.setMethod('POST');request.setHeader('Authorization', sasToken);request.setHeader('Content-Type', 'application/vnd.microsoft.servicebus.json');String strBody = fetchBody();request.setBody(strBody);request.setEndpoint(eventEndPoint);HttpResponse response = http.send(request);
JSON Body
[ { "BrokerProperties": { "ContentType": "application/cloudevents+json" }, "UserProperties": { "origin": "cmp" }, "Body": { "specversion": "1.0", "type": "contact.change", "source": OrgURL + "0032z000008bz7bAAA", "origin": "cmp", "id": "36a8f564-ce7c-2572-cf6a-3d910cea7de4", "subject": "update", "time": "2022-09-05T14:00:52Z" } }, { "BrokerProperties": { "ContentType": "application/cloudevents+json" }, "UserProperties": { "origin": "cmp" }, "Body": { "specversion": "1.0", "type": "contact.change", "source": OrgURL + "0032z000008cA7AAAU", "origin": "cmp", "id": "db1ca42c-1927-e532-bb92-4606092828aa", "subject": "update", "time": "2022-09-05T14:00:52Z" } }, { "BrokerProperties": { "ContentType": "application/cloudevents+json" }, "UserProperties": { "origin": "cmp" }, "Body": { "specversion": "1.0", "type": "contact.change", "source": OrgURL + "0032z000007vef7AAA", "origin": "cmp", "id": "a77c3d7b-e883-ac07-7be2-c50c290e7b83", "subject": "update", "time": "2022-09-05T14:00:52Z" } }]I am getting 400-Bad Request error but once I remove Content Type in header it is sending as Single message instead of bulk. I am following guideline written in https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-batchPlease let me know if anyone have idea how to setup content type for batch topics.1 个回答
I see you have setup "ContentType": "application/cloudevents+json"Can you try application/json and see if the same error is thrown?Based on https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/async_api_headers_content_type.htmField name: Content-TypeField values:application/json (JSON is the preferred format.)application/xml (XML is the preferred format.)text/csv (CSV is the preferred format. Except for bulk query results, responses are returned in XML.)Thanks