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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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)\"

  • Priyank Bhavsar Profile Picture
    505 on at

    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.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • Community member Profile Picture
    2 on at
    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, "");

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
AS-17030037-0 Profile Picture

AS-17030037-0 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans