Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Error happened when try to update data

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, I try to update data with Odata api, I use patch method send data to following url:

https://api.businesscentral.dynamics.com/v1.0/10333be4-6a7e-41e3-a272-c2a11625f23e/ODataV3/Company('CRONUS%20US')/Sales_Order(S-ORD101003)

the data I send is use json:

{
    "WorkDescription": "testtes:1550480116"
}

But I get error:

{
    "odata.error": {
        "code": "",
        "message": {
            "lang": "en-US",
            "value": "Bad Request - Error in query syntax."
        }
    }
}

May I know how to solve?

*This post is locked for comments

  • saicharan Profile Picture
    saicharan 4 on at
    RE: Error happened when try to update data

    It works for me but is there any possibility that if I want to update more than one sales orders at once like all are of Document Type:: Order but Sales order No is different

  • adityamohite Profile Picture
    adityamohite 77 on at
    RE: Error happened when try to update data

    Hi Robert,

    Could you post the solution to your problem here? It would be helpful

  • frankiPL Profile Picture
    frankiPL 15 on at
    RE: Error happened when try to update data

    Hi

    Could you post your solution to this problem?

    I have similar errors and can't make it work.

    Best,

    Marek

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error happened when try to update data

    Thank you, I finally find out how to update, thank you very much

  • I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: Error happened when try to update data

    the key should be correct unless you had published wrong page , which page you are publishing for the web service ?

    is it page 42 ?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error happened when try to update data

    Hello, I also try this way, but still not work

    api.businesscentral.dynamics.com/.../Company('Foxit%20Software%20Incorporated')/Sales_Orders(Document_Type='Order',Document_No='SO1900231')

    get response:

    {

       "error": {

           "code": "BadRequest_NotFound",

           "message": "The number of keys specified in the URI does not match number of key properties for the resource 'NAV.Sales_Orders'."

       }

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error happened when try to update data

    Hello, I use your way to update, but get error response like follow:

    {
        "error": {
            "code": "RequestDataInvalid",
            "message": {
                "lang": "en-US",
                "value": "Request data is invalid."
            }
        }
    }

  • I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: Error happened when try to update data

    If using OData , you should specify all the primary key , in this case for sales order should be  :  Sales_Order('Order','S-ORD101003').

    For updating data ,  you need to get the etag first , call the GET command first :

    GET api.businesscentral.dynamics.com/.../Company('CRONUS%20US')/Sales_Order('Order','S-ORD101003')

    the response will return etag information . then you need to add this etag value under request header when update.

    Request Header

    Key : IF-Match

    Value : etag

    (Sample : W/"JzY4O0pBQUFBQUNMQVFBQUFBSjcvMU1BU1FBdEFERUFPUUF0QURBQU13QXRBREFBTUFBd0FEQUFNQUF3QURJQUFBQUFBQT09Njs5OTAzNjgwOyc=")

    PUT  api.businesscentral.dynamics.com/.../Company('CRONUS%20US')/Sales_Order('Order','S-ORD101003')

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans