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)

Error happened when try to update data

(1) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • I Gusti Made Ari Profile Picture
    3,600 on at

    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')

  • Community Member Profile Picture
    on at

    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."
            }
        }
    }

  • Community Member Profile Picture
    on at

    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'."

       }

    }

  • I Gusti Made Ari Profile Picture
    3,600 on at

    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
    on at

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

  • frankiPL Profile Picture
    15 on at

    Hi

    Could you post your solution to this problem?

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

    Best,

    Marek

  • adityamohite Profile Picture
    77 on at

    Hi Robert,

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

  • saicharan Profile Picture
    4 on at

    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

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