web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

OData - Cannot update data on page :-(

(0) ShareShare
ReportReport
Posted on by

Hi

Can anyone help me how to solve this problem, i am trying to update data on a page via ODataV4 in NAV 2017?

It works perfect when i get or create a new record via OData, but when i try to update data, then i get the following error:

    "code":"","message":"'MERGE' requests for 'Collection' are not supported by Microsoft Dynamics NAV OData web services."

When i read the documentation it should be possible by using:  PUT OR  MERGE

But i am getting the same error from using both commands.

I use the ETAG value that is provided from GET, by creating a JSON response;

{

""data"":""data to update"",

       ""ETag"" : ""32;SZQ1dwCRpzWnZSUFeUqPzD4tPQ7CnAAA6;8063650;""

}

Thanks on advance :-)

/Graves Kilsgaard

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    keoma Profile Picture
    32,729 on at

    if you use a list page as published odata webservice try to use the according card page instead.

  • Community Member Profile Picture
    on at

    Hi Jonathan

    Thanks for your answer, I am using the Card page.

    I have come a solution a bit further, i needed to filter the data to one row.

    But the token (think it is the etag) is still giving me a hard time, i cannot get NAV to validate it :-(

    /Graves

  • Suggested answer
    dkatson Profile Picture
    2,263 on at

    Hi Graves, try to update your data in NAV through OData by using Excel for. example. or open OData test resources (like services.odata.org/validation). Just for to understand if it works. If it works there, than something wrong in your external code. If it  doesn't work there check user permissions , by whom you connect to NAV.

  • Community Member Profile Picture
    on at

    Hi

    It is working perfect when i GET and POST, but it is the PATCH (UPDATE) statement i am having problems with :-(

    I get the following error in Google (postman) and powershell when i try to address the ODATA feed:

    Invoke-RestMethod : {"odata.error":{"code":"","message":{"lang":"en-US","value":"Could not validate the client concurrency token required by the service. Please provide a valid token in the client request."}}}


    I have worked with the assumption that it is the etag that i have wrong, but it looks right:
    I am sending a header that looks like this:

    Key          Value                                                          
    ---          -----                                                          
    accept       application/json                                               
    etag         "'36%3BJAAAAACLAQAAAAJ7BDEAMAAwADcAAAAAAA%3D%3D7%3B10073950%3B'"
    Content-Type application/json               


    And as body i send a json file with the changes i would like to change in my NAV Service:

    Invoke-RestMethod -Uri $NAVServiceURL -Method PATCH -Credential $NAVServiceUserCreds -ContentType "application/json" -Body $Dataupdate -Headers $headers

    think it is very weird :-/

    /Graves

                                    

  • Suggested answer
    dkatson Profile Picture
    2,263 on at

    Did you created User Web access key?

    See my blog about MS Flow, it also use OData

    community.dynamics.com/.../how-ms-flow-can-make-a-friendship-with-nav2017

  • Community Member Profile Picture
    on at

    Hi

    At the moment I use: UserPassword, but connection is fine, i can Create and Get data from the service.

    The problem i have is that i cannot get the request right to build an OData request that updates data with a PATCH.

    What I cannot figure out what it is i am missing when the service tells me:

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

    /Graves

  • dkatson Profile Picture
    2,263 on at

    Hi, try to replace UserPassword with Service Access Key for this user.... Just try, may be this could help, if not ... will think furher

  • Verified answer
    Community Member Profile Picture
    on at

    Hi

    I hav now found the solution..

    The problem was that i had to include the ETag in the headder, with the If-Match parameter.

    # ----- Build new headder for update -----
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("accept","application/json")
    $headers.Add("If-Match",'W/"' + "'" + [uri]::EscapeDataString($JToken.ETag.ToString()) + "'" + '"') #Etag Value
    $headers.add("Content-Type","application/json; charset=utf-8")
    


    /Graves

  • Community Member Profile Picture
    on at

    Hi Graves,

    Currently i have the same problem.

    Can you post us your whole Request?

    Thanks

    Martin

  • Suggested answer
    gert@lynge.org Profile Picture
    on at

    Hi

    Graves is one of my friends, and he is currently on holiday, so I'm not sure he will se your message.

    Anyway, we worked together on this blog-post after he solved the issue.

    Unfortunately it is in Danish, but it is mainly powershell anyway.

    You can probably see the request and inner workings from the powershell example code (powershell making misc. webservice calls to NAV).

    blog.systemconnect.dk

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans