Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Cloud REST API sudden problem

Posted on by 13
Hi
 
We have had a system running for a few months with no problems
 
Today I am getting an error when updating a sales header. I have reproduced this in Postman. It still works on a local installation, but not on the cloud installation.
 
Call this endpoint:
 
 
With some data and always get:
 
{
    /error/: {
        /code/: /BadRequest/,
        /message/: /Invalid Request Body  CorrelationId:  42968f61-0607-4262-827d-4a0c75c26542./
    }
}
 
I have tried removing almost all of the body, but I get the same result whatever the body is. I have tried doing a GET and posting the response as a PATCH, just to update the record with the exact same information, making 100% sure all fields are correctly named etc, but it says the same
 
I have had this BadRequest error before and it is usually because you are providing an incorrect variable in the body. So I removed all of them to check which one it is, but it still says BadRequest
 
Same update works on a local installation, with the same REST API installed
 
So, has Microsoft done any kind of update that is breaking this? How do I fix it? Is it possible to see some logging with more details?
  • Verified answer
    Community member Profile Picture
    Community member 13 on at
    Cloud REST API sudden problem
    It has worked before and suddenly stopped working. It still works on premise

    We have now solved the issue. The problem is that the body contains the @odata.context and @odata.etag tags. They were accepted/ignored before, but are now causing an error. When I remove those tags and put the If-Match header in, it works as expected

    So it seems to be related to an update to Business Central Cloud
  • Community member Profile Picture
    Community member 13 on at
    Cloud REST API sudden problem
    Thanks for the answer
     
    We are using a custom page and therefore the name I use is actually correct and as I said it has worked fine before
     
    Our page takes the type and no as the key. The standard page takes an ID
     
    I just tried to update the sales quote with the standard page and this works as expected. But I have no idea why our custom page stopped working. It keeps saying Invalid body
     
    Posting the exact same body to the standard salesQuotes works as expected
     
    Posting the same body (just removing odata.context, odata.etag and No from the body) also works at creating a new sales quote with our custom page
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 68,586 Super User 2024 Season 2 on at
    Cloud REST API sudden problem
    Hi, first of all, as far as I know, none of the standard APIs is called SalesHeader. If you need to update the Sales Header, you need to use the following standard APIs, salesOrders,salesQuotes or salesInvoices
    For example,
     
    From the filtering in your Endpoint, you want to update salesQuotes.
    So you need to do the following:
    Get sales quote: https://api.businesscentral.dynamics.com/v2.0/c8558e71-6ad8-4fcd-9f29-3ca165b41bbe/Sandbox223/api/v2.0/companies(554f4f15-9c8e-ee11-be3e-6045bde96b9a)/salesQuotes(976ffabc-90ab-ee11-a56a-6045bd686202)
     
    Update sales quote:
     
    Hope this helps.
    Thanks.
    ZHU

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,326 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,166 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans