Skip to main content

Notifications

Sending batch request in postman using Data entities in Dynamics 365 for finance and operations

Sukrut Parab Profile Picture Sukrut Parab 71,656 Moderator

I have seen multiple people asking about how to send multiple transactions in D365 Finance and operations  using postman to test Data entities. Here  is blog post for that.

Postman is handy tool when  you want to test restful API’s. You can simply create entity in D365 finance and operations, create an endpoint or directly post it using ODATA endpoint and test it using postman. You can refer below link to now more about how you can test your entities  using third party utilities

https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/third-party-service-test

The normal scenario of sending single transaction works perfect when you use postman . However If you want to send multiple transactions entity  throws you exception which looks similar to following exception.

The property 'data' does not exist on type 'Microsoft.Dynamics.DataEntities.SalesOrder'. Make sure to only use property names that are defined by the type"

 If you want to send multiple transaction , you have to send your transactions using batch request in postman.

For sending batch request set up postman header content type as Multipart/Mixed like shown in below screenshot.

If you would like to know more about Multipart ContentType check below link

https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

postman2.JPG

The body of the request looks like below . I am using standard LegerJournalEntity to post my request .

Request.

--batch_7bf57939-a923-4e49-92d3-20fb4f2c8435
Content-Type: multipart/mixed; boundary=changeset_8a6f6ebe-e9c9-44a2-b980-c33a69370eb4

--changeset_8a6f6ebe-e9c9-44a2-b980-c33a69370eb4
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1

POST /data/CaaLedgerEntity  HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
Content-Type: application/json;odata.metadata=minimal
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft.OData.Client/7.5.4
Authorization: Bearer {Bearer Token}

 {
      "dataAreaId":"caa","JournalBatchNumber":"","LineNumber":106622,"ReverseEntry":"No","ItemSalesTaxGroup":"","CashDiscountDate":"1900-01-01T12:00:00Z","Voucher":"1996071096","Text":"RECLASS 7-10-96 8239","OnOffcycleJournalDesc":"No","JournalName":"Daily","OffsetAccountType":"Ledger","IsWithholdingCalculationEnabled":"No","ReverseDate":"1900-01-01T12:00:00Z","TransDate":"1996-07-10T12:00:00Z","DefaultDimensionDisplayValue":"","PaymentReference":"","CashDiscountAmount":0,"ChineseVoucherType":"","DebitAmount":4177.78,"SalesTaxCode":"","OffsetAccountDisplayValue":"","AccountDisplayValue":"485300--CORP---LOSANGELES-----","CashDiscount":"","DocumentNum":"","BookingNumber":"","Description":"General Journal","OffsetDefaultDimensionDisplayValue":"","SalesTaxGroup":"","AccountType":"Ledger","Invoice":"","DueDate":"1900-01-01T12:00:00Z","PaymentId":"","PaymentMethod":"","CreditAmount":0,"ExchangeRateSecondary":0,"Quantity":0,"BookingLineNum":0,"TaxExemptNumber":"","CurrencyCode":"USD","Company":"caa","ChineseVoucher":"","DiscountPercentage":0,"OffsetText":""
    }
--changeset_8a6f6ebe-e9c9-44a2-b980-c33a69370eb4
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2

POST /data/CaaLedgerEntity HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
Content-Type: application/json;odata.metadata=minimal
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft.OData.Client/7.5.4
Authorization: Bearer {Bearer Token}

{
      "dataAreaId":"caa","JournalBatchNumber":"","LineNumber":106622,"ReverseEntry":"No","ItemSalesTaxGroup":"","CashDiscountDate":"1900-01-01T12:00:00Z","Voucher":"1996071096","Text":"RECLASS 7-10-96 8239","OnOffcycleJournalDesc":"No","JournalName":"Daily","OffsetAccountType":"Ledger","IsWithholdingCalculationEnabled":"No","ReverseDate":"1900-01-01T12:00:00Z","TransDate":"1996-07-10T12:00:00Z","DefaultDimensionDisplayValue":"","PaymentReference":"","CashDiscountAmount":0,"ChineseVoucherType":"","DebitAmount":4177.78,"SalesTaxCode":"","OffsetAccountDisplayValue":"","AccountDisplayValue":"485300--CORP---LOSANGELES-----","CashDiscount":"","DocumentNum":"","BookingNumber":"","Description":"General Journal","OffsetDefaultDimensionDisplayValue":"","SalesTaxGroup":"","AccountType":"Ledger","Invoice":"","DueDate":"1900-01-01T12:00:00Z","PaymentId":"","PaymentMethod":"","CreditAmount":0,"ExchangeRateSecondary":0,"Quantity":0,"BookingLineNum":0,"TaxExemptNumber":"","CurrencyCode":"USD","Company":"caa","ChineseVoucher":"","DiscountPercentage":0,"OffsetText":""
    }
--changeset_8a6f6ebe-e9c9-44a2-b980-c33a69370eb4--
--batch_7bf57939-a923-4e49-92d3-20fb4f2c8435--

 

Once the request is sent the journals are created Finance and operations immediately. Take a look at below response and Journals created screen shot.

postman1.JPG

 

postman3.JPG

 

Feel free to ask , if you have any questions. 



Comments

*This post is locked for comments

  • J Tang Profile Picture J Tang 5
    Posted at
    Getting the same issue as Darji. Does anybody have a solve?
  • Darji Puneet Profile Picture Darji Puneet
    Posted at
    I tried your way but I get response as --batchresponse_32a7ab5c-648a-444a-8633-f8b08f6291ba Content-Type: application/http Content-Transfer-Encoding: binary HTTP/1.1 204 No Content Any idea?
  • Tadas K. Profile Picture Tadas K. 20
    Posted at
    great work. thank you Sukrut Parab.
  • junior AX Profile Picture junior AX 1,548
    Posted at
    Hi Sukrut, What abot creating sales order (header and lines) does it work in this way? If yes how can i take the value of the salesId from the first post ooeration and use it for creating lines?
  • Sukrut Parab Profile Picture Sukrut Parab 71,656 Moderator
    Posted at
    Hi Magnus , I did not try csv file . I will check linked article by you and let you know.
  • Magnus Holm-Berger Profile Picture Magnus Holm-Berger
    Posted at
    Thanks for sharing! Do you know how to push multiple transactions to FinOps through CSV-file? I am trying to set up a push request by importing a JSON-script and uploading a CSV-file with a few test-lines ( following this article learning.getpostman.com/.../working_with_data_files ) to {{resource}}/data/CustomerGroup, but it does not create the lines in the d365 environment. Have you tested this method of pushing in transactions?