When call lnv_HttpClient.SendRequest("GET", lsurl, lsboby)
On some PC it show "Bad Request - Invalid Verb" this error
but it works on postman.
Develop on Appeon PowerBuilder 2019 R2 Build 2353
Deploy on Windows 10 64Bit
My Code
Integer li_rc
String ls_string, lsboby
HttpClient lnv_HttpClient
lnv_HttpClient = Create HttpClient
lnv_HttpClient.SetRequestHeader("Content-Type", "application/json")
string lsurl, lsid, lssql
lsurl = "http://mydomain/myapp/api/sysfunction/sql"
lsid = "test"
lssql = "select item_code, item_name from item_master where item_code = 'CH'"
lsboby = '"{ '
lsboby = lsboby + ' \"corporateid' + '\": \"' + lsid + '\", ~r~n'
lsboby = lsboby + ' \"sql\": \"' + lssql + '\"'
lsboby = lsboby + ' }"'
li_rc = lnv_HttpClient.SendRequest("GET", lsurl, lsboby)
lnv_HttpClient.GetResponseBody(ls_string)
mle_1.text = ls_string
Error:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Verb</h2>
Thank you
Kiran Patel
Adding a body to a GET request is not something I would use, but interestingly earlier versions of Postman wouldn't let you send a body with a GET request, but the latest versions do, so there must be some demand for it.
I tested the HttpClient in Powerbuilder 2019 R2 (Build 2328) earlier this week and it does send the body with a GET request. It even sets the Content-Length header which I didn't think it would. If you send a body with a GET request, it's really up to the Server to accept it, and then up to the specific API to handle it. Kiran has said that it works from his PC and logs it on the server so presumably the API handles it ok. Requests from the client don't work, but he does say that requests from the client aren't logged on the server, which is weird. I wonder whether the request from the client is intercepted by an upstream proxy and rejected before it reaches the server. Or whether the URL on the client resolves to a different IP Address than on his PC.
It is unclear whether Kiran has written the API or has access to the source code. If so the easiest thing would be to change it all to use POST, but if it is someone else's API he may be stuck with it as it is.