HTTPRequest with DELETE method having error 400: Bad Request

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Rudolf
Newbie
Posts: 7
Joined: Tue May 30, 2006 8:28 am

HTTPRequest with DELETE method having error 400: Bad Request

Post by Rudolf » Thu Jul 27, 2023 6:54 am

Hi,
UPDATE: My engineer says the request body is not sent to the server
I'm working on a script.

Portion of the script:
Code to disable account is working fine.

Code: Select all

Let>nextLine=%CRLF%
Let>caHeader=
Let>responseFile=C:\XAMS\RESPONSE.txt

ConCat>caHeader,Content-Type: application/json; charset=utf-8
ConCat>caHeader,nextLine
ConCat>caHeader,Accept: application/json; charset=utf-8

//===smoke-ABCX_05-DISABLE-ACCOUNT=========================
WriteLn>responseFile,nWLNRes,//===smoke-ABCX_05-DISABLE-ACCOUNT=========================
Let>HTTP_CUSTOM_HEADERS=%caHeader%

ReadFile>C:\XAMS\smoke-ABCX_05-DISABLE-ACCOUNT.txt,json_data
WriteLn>responseFile,nWLNRes,HTTP_CUSTOM_HEADERS
WriteLn>responseFile,nWLNRes,json_data
HTTPRequest>https://abcx2001.test.abcx.net:9022/Users/v1/accounts/suspended,,POST,json_data,HTMLResponse,,,,
WriteLn>responseFile,nWLNRes,HTMLResponse
wait>5
Ask>Continue?,strResponse
Code to Enable account keeps showing "400 HTTP/1.1 400 Bad Request".
No error on server end.

Code: Select all

Let>nextLine=%CRLF%
Let>caHeader=
Let>responseFile=C:\XAMS\RESPONSE.txt

ConCat>caHeader,Content-Type: application/json; charset=utf-8
ConCat>caHeader,nextLine
ConCat>caHeader,Accept: application/json; charset=utf-8

//===smoke-DMGX_06-RESTORE-ACCOUNT=========================
WriteLn>responseFile,nWLNRes,//===smoke-DMGX_06-RESTORE-ACCOUNT=========================
Let>HTTP_CUSTOM_HEADERS=%caHeader%

ReadFile>C:\XAMS\smoke-DMGX_06-RESTORE-ACCOUNT.txt,json_data
WriteLn>responseFile,nWLNRes,HTTP_CUSTOM_HEADERS
WriteLn>responseFile,nWLNRes,json_data
HTTPRequest>https://abcx2001.test.abcx.net:9022/Users/v1/accounts/V123GI,,DELETE,,HTMLResponse,,,,
WriteLn>responseFile,nWLNRes,HTMLResponse
wait>5
Ask>Continue?,strResponse
I have same issue with 2 other REST API function that I'm testing, both DELETE method.
So far POST, PUT and GET are all ok.

Thanks for any help provided.

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: HTTPRequest with DELETE method having error 400: Bad Request

Post by Marcus Tettmar » Thu Jul 27, 2023 4:26 pm

Rudolf wrote:
Thu Jul 27, 2023 6:54 am
Hi,
UPDATE: My engineer says the request body is not sent to the server
There is no request body with a DELETE. Please clarify.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Rudolf
Newbie
Posts: 7
Joined: Tue May 30, 2006 8:28 am

Re: HTTPRequest with DELETE method having error 400: Bad Request

Post by Rudolf » Thu Jul 27, 2023 4:53 pm

Hi Marcus,

Oh I see. I understand the issue now.
I'm using the HTTPRequest to test a REST API that my developer created.

Example:
In another function using DELETE method - They programmed the REST API to use the information in the request body to identify the specific permission to remove from a user.

Any advice on how I can workaround this?

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: HTTPRequest with DELETE method having error 400: Bad Request

Post by Marcus Tettmar » Fri Jul 28, 2023 6:28 am

Delete requests with a request body are non standard. Most clients won't support that as it's not in the spec. Macro Scheduler does not support it. Ask your developer if they can make a version of the endpoint which has query parameters instead.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts