Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Modify a record through ODATAV4

Posted on by 3,957

Hi All,

I have a record created in Business Central and is pulled to CDS Correctly. After modifyingthe record in CDS, I want to update my record in Business Central.

The issue is that the table consists 3 key fields Time Sheet No., Time Sheet Line No. and Date.

When I call the url through GET method, I'm precisely getting that single record.

GET.png

When I try to modify the record using PATCH, I'm getting the following error

'Could not validate the client concurrency token required by the service. Please provide a valid token in the client request'

PATCH.png

I have followed this url

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-odata-to-modify-data

I have also passed the Etag as a part of If-Match but that just gives the same result.

Kindly advise!

Categories:
  • Verified answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Modify a record through ODATAV4

    Aaahh....

    You are right.. I made a silly mistake...

    Yes I have confirmed that things are working as desired.

    FYI If-Match = * also works perfectly

    Thanks a lot man.. I guess I needed a second pair of eyes :)

  • Verified answer
    gert-jan.terschure Profile Picture
    gert-jan.terschure 200 on at
    RE: Modify a record through ODATAV4

    From the screenshots I can see you're adding the If-Match and Content-Type to the tab "Params", these will be added to the url. This is intended behavior as the params could contain items such as "$filter" and "$select".

    Please place them in tab "Headers" (3rd tab from the left), that is where the headers that are being sent as part of the request are added.

  • Suggested answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Modify a record through ODATAV4

    Hi Gert,

    Thank you I appreciate your help, but I'm getting the same error.

    I do not understand why If-Match becomes a part of the URL
    PUT.png

    Also, I'm showing the body of the call

    PUIT-BODY.png

    I hope this makes it clear.
    Let me know if you need any more details or we can have a call to understand it further.

  • Verified answer
    gert-jan.terschure Profile Picture
    gert-jan.terschure 200 on at
    RE: Modify a record through ODATAV4

    From the screenshots the If-Match seems to be placed in the url. It needs to be placed in the header. Please note that the @odata.etag that's provided by Business Central/NAV is "escaped json", so you'll need to remove the "\" that are placed in front of the double quotes.

    pastedimage1585805687917v1.png

  • Suggested answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Modify a record through ODATAV4

    Hi,

    Yes I have also tried that but it gives the same result.

  • Verified answer
    gert-jan.terschure Profile Picture
    gert-jan.terschure 200 on at
    RE: Modify a record through ODATAV4

    You need to provide the If-Match header in the PUT request. When you get the result you get the "@odata.etag" property, this is the concurrency token.

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,835 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans