hougaard / Simple-Object-Designer

Issue tracking for the Simple Object Designer for Business Central
7 stars 0 forks source link

PATCH API call errors #100

Closed ghassanm closed 11 months ago

ghassanm commented 2 years ago

Hi Support/Erik I am testing using Postman. When I try PATCH Call, I get the following error message. The standard Microsoft API works fine. Please let me know what I am doing wrong. Thanks Ghassan

The PATCH Call https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/sales_Headers?Company=DiCentral Testing 02-22-22&$filter=id eq "077a55a8-64fb-ec11-82f8-000d3a748922"

"error": {
    "code": "BadRequest_MethodNotAllowed",
    "message": "'PATCH' requests for 'sales_Headers' of EdmType 'Collection' are not allowed within Dynamics 365 Business Central OData web services."
}

}

Header if-Match: W/"JzE5OzEyMDYzMDQyMjE5NzcxNDcwNjgxOzAwOyc=\" Content-Type: application/jason

Body { "BilltoCity": "Dallas" }

hougaard commented 2 years ago

Change your URL to use Company() in the URL instead of Company= in querystring.

ghassanm commented 2 years ago

Hi Erik, I am still getting the same error https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/sales_Headers?Company(DiCentral Testing 02-22-22)&$filter=id eq "077a55a8-64fb-ec11-82f8-000d3a748922"

hougaard commented 2 years ago

No, like this:

https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/companies(<ID>)/sales_Headers

Where is the GUID from the company table.

ghassanm commented 2 years ago

Hi Erik, Getting not found error now. I only need to update the bill-to city for a specific sales order. Thanks in advance https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/companies(f77a1b9c-ee93-ec11-b85a-000d3a747dd5)/sales_Headers&$filter=id eq "077a55a8-64fb-ec11-82f8-000d3a748922"

response { "error": { "code": "BadRequest_NotFound", "message": "No HTTP resource was found that matches the request URI 'https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/companies(f77a1b9c-ee93-ec11-b85a-000d3a747dd5)/sales_Headers&$filter=id%20eq%20%22077a55a8-64fb-ec11-82f8-000d3a748922%22?tenant=msft1a6720t14543701&aid=FIN'." } }

ghassanm commented 2 years ago

Hi Erik, Do you have feedback on the above. The Sales order exists, and the ID is from GET call.

regards, Ghassan

hougaard commented 2 years ago

It's the URL that's still malformed, I think my suggestion was wrong, check this:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/endpoints-apis-for-dynamics

ghassanm commented 2 years ago

Thank for the quick response. Still getting the same error message.

https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/sales_Headers?Company(DiCentral Testing 02-22-22)&$filter=id eq "077a55a8-64fb-ec11-82f8-000d3a748922"

Regards, Ghassan

From: Erik Hougaard @.> Sent: Thursday, August 25, 2022 1:45 PM To: hougaard/Simple-Object-Designer @.> Cc: Ghassan Mteirek @.>; Author @.> Subject: Re: [hougaard/Simple-Object-Designer] PATCH API call errors (Issue #100)

Change your URL to use Company() in the URL instead of Company= in querystring.

— Reply to this email directly, view it on GitHubhttps://github.com/hougaard/Simple-Object-Designer/issues/100#issuecomment-1227635022, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAJW3HN5UPWGMAW3UQXGOQ3V265MNANCNFSM57UEZEHA. You are receiving this because you authored the thread.Message ID: @.**@.>>

hougaard commented 2 years ago

Still malformed, try:

https://api.businesscentral.dynamics.com/v2.0/6fd97b54-3483-4f7e-8d06-685564656d2d/Integration/api/hougaard/FHF/v2.0/company(xxxx-yyyy-zzzzzzzz)/sales_Headers/?

where xxxxxx-yyyy-zzzzzzzzzzzzz is the ID of your company (not name) and the if-match has the ID of the sales header