Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to create records ...
Finance forum
Unanswered

How to create records successfully using odata in postman

Posted on by 1,548

Hi,

So I'm trying to do post an order in D365 using postman (oData)

 For the create operation (post) if i use 

environmentURL/data/SalesOrderHeaders   or  environmentURL/data/SalesOrderHeadersV2

1. what should i do exactly, what i should i fill the body with?

2. How to create Lines as well?

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: How to create records successfully using odata in postman

    Hi Martin and Anitha,

    I will try doing it in c# sooon

    I tried SalesOrderHeaders where i passed few things:

    {

      "dataAreaId": "USMF",  

      "DeliveryAddressCountryRegionId": "UK",

      "DeliveryAddressCountyId": "UK",

      "DeliveryAddressStateId": "UK",

      "DeliveryAddressCity": "City",

      "InvoiceCustomerAccountNumber": "us-001",

      "OrderingCustomerAccountNumber":"us-001",

     "CurrencyCode":"GBP",

     "LanguageId":"en-gb"

    }

    and it worked.. i will try SalesOrderHeadersV2 and let u knw the result

    about the lines, i will try in in another request. However, can i not do it in one request?... i mean if one of the lines failed then header should fail as well.

    So how can i make it in one request?

  • AnithaEswaran Profile Picture
    AnithaEswaran 2,030 on at
    RE: How to create records successfully using odata in postman

    Hi,

    I use SalesOrdersHeadersV2 and use the needed fields in my postman request. You can exclude/include a few of the below fields if not needed for your requirement. 

    {

       "dataAreaId": "USMF",    

       "SalesUnitId": "",

       "SalesOrderName": "TestingSalesORder",

       "MultilineDiscountCustomerGroupCode": "",

       "DeliveryAddressLocationId": "",  

       "DeliveryAddressCountyId": "",

       "DeliveryAddressCountryRegionISOCode": "ABS",

       "TransportationRoutePlanId": "",

       "CustomerPaymentFineCode": "",

       "SalesOrderPromisingMethod": "SalesLeadTime",  

       "ConfirmedShippingDate": "1900-01-01T12:00:00Z",

       "FiscalOperationPresenceType": "DoesNotApply",

       "BankConstantSymbol": "",

       "RequestedReceiptDate": "2021-03-20T12:00:00Z",

       "CustomerPaymentMethodName": "CC",

       "DeliveryAddressDistrictName": "",

       "DeliveryAddressDunsNumber": "",

       "ServiceFiscalInformationCode": "",

       "PaymentScheduleName": "",

       "IntrastatTransactionCode": "10",

       "PaymentTermsName": "N30",

       "OrderingCustomerAccountNumber": "ABC1234",

       "QuotationNumber": "",

       "CurrencyCode": "USD",

       "DirectDebitMandateId": "",

        "DeliveryAddressCity": "XXXX",

       "DeliveryAddressStreet": "Business park",

       "DeliveryAddressZipCode": "7777"

    }

    Similarly I used SalesOrderLines to create lines and pass the SalesId created from the earlier request

    {

    "dataAreaId": "USMF",

    "SalesOrderNumber": "000116",

    "ItemNumber": "106",

    "ShippingSiteId": "1",

    "OrderedSalesQuantity": 2,

    "DeliveryModeCode": "USD",

    "RequestedShippingDate": "2020-10-20T00:00:00Z",

    "SalesUnitSymbol": "ea",

    "SalesPrice": 30

    }

    Note, the names you pass in the request should be same as the field names in the entity. Otherwise, the request would throw error. 

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: How to create records successfully using odata in postman

    I'm sorry, but I don't understand what you mean.

    Postman is about making HTTP requests (including headers and things like that). It's true that some some services, including OData, uses JSON format in request body (if there is any body at all), and that JSON contains key-value pairs, among other things. You may be interested in fields, but you just ignore the rest of what Postman does.

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: How to create records successfully using odata in postman

    Hi Martin,

    How can i copy c# code?

    Isn't postman about filling key - value fields?

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: How to create records successfully using odata in postman

    If I was you, I wouldn't start by trying to write everything from scratch by myself. I would generate classes for OData services (see the sample application from Microsoft on GitHub) and write code with these classes (with code completion, compile-time checking etc.), which is much easier. Then I would run the code and observe messages sent to F&O.

    Then you can also copy these messages, adjust them and use them in Postman.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans