Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to use D365FOUrl/data/$batch to create a sales order with header and lines (single transaction) using postman

(0) ShareShare
ReportReport
Posted on by 1,549

- I've added Content -Type in the Header with value = multipart/mixed;boundary=batch_d63a-e9be-2927

1. what does this content type mean and what does this batch value mean d63a-e9be-2927?

- I've added this in the body ( raw - Text) 

--batch_d63a-e9be-2927
Content-Type: multipart/mixed; boundary=changeset_2499-90ab-7b93

--changeset_2499-90ab-7b93
Content-Type: application/http
Content-Transfer-Encoding: binary

POST SalesOrderHeadersV2?cross-company=true HTTP/1.1
Content-ID: 1
Accept: application/json;q=0.9, */*;q=0.1
OData-Version: 4.0
Content-Type: application/json
OData-MaxVersion: 4.0

{
    "dataAreaId": "usmf",
    "LanguageId": "en-GB",
    "CurrencyCode": "GBP",
    "InvoiceCustomerAccountNumber": "us-001",
    "OrderingCustomerAccountNumber": "us-001"
}
--changeset_2499-90ab-7b93--

--batch_d63a-e9be-2927
Content-Type: multipart/mixed; boundary=changeset_b573-33b2-85ff

--changeset_b573-33b2-85ff
Content-Type: application/http
Content-Transfer-Encoding: binary

POST SalesOrderLines?cross-company=true HTTP/1.1
Content-ID: 2
Accept: application/json;q=0.9, */*;q=0.1
OData-Version: 4.0
Content-Type: application/json
OData-MaxVersion: 4.0

{
    "dataAreaId": "usmf",
    "ItemNumber":"D0001",
    "SalesPrice": 30,
    "SalesUnitSymbol": "ea",
    "OrderedSalesQuantity": 10
}
--changeset_b573-33b2-85ff--

2. should this create a sales order with header and lines in a single transaction, i mean if the line fails will the header fail as well?

- When i run it, the header got created succesfully, However the line failed
  "error":{
    "code":"","message":"An error has occurred.","innererror":{
      "message":"Additional text encountered after finished reading JSON content: -. Path '', line 8, position 0.","type":"Newtonsoft.Json.JsonReaderException","stacktrace":"   at Newtonsoft.Json.JsonTextReader.Read()\r\n   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.GetCompanyFromRequest()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataController.Post()\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.

3. how to solve this error

  • .. Profile Picture
    1,549 on at
    RE: How to use D365FOUrl/data/$batch to create a sales order with header and lines (single transaction) using postman

    Hi will,

    Based on the link you provided.. It seems if i use the same changeset i can create records in  single trransaction

    But would it work for header and lines?

    Can you please help me in how to edit the code above to make it work in postman?

  • WillWU Profile Picture
    22,357 on at
    RE: How to use D365FOUrl/data/$batch to create a sales order with header and lines (single transaction) using postman

    Hi partner,

    Please check this:docs.microsoft.com/.../odata

  • .. Profile Picture
    1,549 on at
    RE: How to use D365FOUrl/data/$batch to create a sales order with header and lines (single transaction) using postman

    Hi will,

    1. So this batch is only used to call multiple urls together and not to call them in a single transaction so if one fails the other one can be called successfully?

    2. What's tbe benefit of this batch url? When will i need to use it

    3. What do u mean by by cross company and what should i do exactly?

  • WillWU Profile Picture
    22,357 on at
    RE: How to use D365FOUrl/data/$batch to create a sales order with header and lines (single transaction) using postman

    Hi IntegrationBeginner,

    1, The POST request containing the batch must have a Content-Type header with a value set to multipart/mixed with a boundary set to include the identifier of the batch using this pattern, The unique identifier doesn't need to be a GUID, but should be unique. Each item within the batch must be preceded by the batch identifier with a Content-Type and Content-Transfer-Encoding header

    2, Answered in your other thread.

    3. How it will happens if you call it without cross company ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 487 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

#3
Saalim Ansari Profile Picture

Saalim Ansari 291

Overall leaderboard

Product updates

Dynamics 365 release plans