Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dyanmics 365 web API giving "Bad Request - Error in query syntax" error.

(0) ShareShare
ReportReport
Posted on by 505

I'm posting the following json to create an order product in Dynamics 365 online (V 9.0).

"{\"productid@odata.bind\":\"/products(ea69cd50-5e58-e811-a954-000d3a33e5a2)\",\"salesorderid@odata.bind\":\"/salesorders({3818B268-D25D-E811-A958-000D3A33E5A2})\",\"uomid@odata.bind\":\"/uoms(9964520C-7B37-E811-A953-000D3A3099E5)\",\"wo_lotnumber\":\"5$\",\"priceperunit\":1000,\"isproductoverridden\":false}"

The API is giving "Bad Request - Error in query syntax" error.

Can someone let me know what could be wrong with my Json?

*This post is locked for comments

  • Dyanmics 365 web API giving "Bad Request - Error in query syntax" error.
    Came in to validate this. It applies even to context.WebApi.CreateRecord in PCF controls. So frustrating because you would NEVER be able to gather this from the error message. You can use string replace like this:
     
    let value = "{f98f4441-09d7-4f00-a19d-70c27d9216a5}";
    return value.replace(/[{}]/g, "");
  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Dyanmics 365 web API giving "Bad Request - Error in query syntax" error.

    Try to use

    "{\"productid@odata.bind\":\"/products(ea69cd50-5e58-e811-a954-000d3a33e5a2)\",\"salesorderid@odata.bind\":\"/salesorders(3818B268-D25D-E811-A958-000D3A33E5A2)\",\"uomid@odata.bind\":\"/uoms(9964520C-7B37-E811-A953-000D3A3099E5)\",\"wo_lotnumber\":\"5$\",\"priceperunit\":1000,\"isproductoverridden\":false}"

    instead of your original request. As you mentioned without curly brackets around salesorderid - works, when you have it like in initial request - it does not.

  • Priyank Bhavsar Profile Picture
    Priyank Bhavsar 505 on at
    RE: Dyanmics 365 web API giving "Bad Request - Error in query syntax" error.

    Thanks a lot Andrew the curly braces was the culprit. I misunderstood what you meant to say in the first reply but now got your point.

  • Verified answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Dyanmics 365 web API giving "Bad Request - Error in query syntax" error.

    Hello,

    WebApi doesn't like curly brackets. My first shot is try to replace

    "/salesorders({3818B268-D25D-E811-A958-000D3A33E5A2})\"

    with

    "/salesorders(3818B268-D25D-E811-A958-000D3A33E5A2)\"

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! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans