I am using httpapi to perform a POST request, the expected result is a JSON file that i want to save in the IFS for later use. The JSON contains a JWT token but that is not important now.
I tried the request using SOAP UI and it works smooth, trying to replicate the request via httpapi a get an error.
Here is the raw request as it appears on the SOAPUI client window
POST https://xxxxxxx.xxxx.xx/identityserver/ ... &scope=ccc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 82
Host: xxxxxxx.xxxx.xx
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
here is the raw response from SOAP UI client
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, max-age=0
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
Server: Microsoft-IIS/8.5
X-Powered-By: ARR/3.0
Date: Tue, 07 Jun 2022 12:31:35 GMT
Content-Length: 803
{"access_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IjM5ODUzQzhBOEI3RjU2QkJBQ0IxMzg2QjBDOTdBNkJFNzE0OENFRkUiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJPWVU4aW90X1ZydXNzVGhyREplbXZuRkl6djQifQ.eyJuYmYiOjE2NTQ2MDUwOTgsImV4cCI6MTY1NDYwODY5OCwiaXNzIjoiaHR0cHM6Ly9zZXJ2aXppLmZpZ2MuaXQvaWRlbnRpdHlzZXJ2ZXIiLCJhdWQiOlsiaHR0cHM6Ly9zZXJ2aXppLmZpZ2MuaXQvaWRlbnRpdHlzZXJ2ZXIvcmVzb3VyY2VzIiwiTE5EIl0sImNsaWVudF9pZCI6IkxuZENsaWVudCIsInNjb3BlIjpbIkxORCJdfQ.YyNbsNrBsnmTJABN2YXzwzjFEm3o6zXcLe_X6Ha9H95WkSGkOJNIt0Wj0G9WfNJtKJXjb24ZXW_Ml2-2yy8sYS3zeDfOyjJHFvSZOSHr2sy2ePvBd68oqG62ELAnYBW90XAk69sBuQsUoJQv6V_TzRSApggy5TDV-NAAt4FuNmqriTv6ckFhbxXzlDnHhakphmBf6UGlVOQF0QB5-pMHJ3buUVlIPhk9rHg583d2EAypmZfyE5LuNIGPDhe8X8zAELSYFEWEALYyWOJiFFvOHWs-BIJFKPl9F18QN3ItJAA1L1SJeq2ytHI2lIKgKXol04O-m7ayL7pOuI_aEavHnQ","expires_in":3600,"token_type":"Bearer"}
here is my rpg snippet code
Code: Select all
http_debug(*ON: debugLog + 'httpapi_testLog.log');
http_setCCSIDs( 1208: 0 );
URLTOJWT='https://xxxxxxx.xxxx.xx/identityserver/connect/token';
postData='?client_id=' + %Trim(TClientId) +
'&client_secret=' + %Trim(TClientSecret) +
'&grant_type=' + %Trim(TGrantType) +
'&scope=' + %Trim(TScope);
IFS=debugLog + 'httpapi_testJSON.json';
rc = http_post(URLTOJWT
: %addr(postData) + 2
: %len(postData)
: IFS
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/x-www-form-urlencoded' );
Protocol Used: TLS Version 1.2
http_persist_post(): entered
http_persist_req(POST) entered.
http_long_ParseURL(): entered
http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /identityserver/connect/token HTTP/1.1
Host: xxxxxxx.xxxx.xx
User-Agent: http-api/1.45
Content-Type: application/x-www-form-urlencoded
Content-Length: 83
senddoc(): entered
?client_id=aaaaaaa&client_secret=bbbbbb&grant_type=client_credentials&scope=ccc
recvresp(): entered
HTTP/1.1 400 Bad Request
Cache-Control: no-store, no-cache, max-age=0
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
Server: Microsoft-IIS/8.5
X-Powered-By: ARR/3.0
Date: Tue, 07 Jun 2022 13:07:15 GMT
Content-Length: 26
SetError() £13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 26
header_load_cookies() entered
recvdoc(): entered
SetError() £0:
recvdoc(): Receiving 26 bytes.
{"error":"invalid_client"}
SetError() £13: HTTP/1.1 400 Bad Request
http_close(): entered
and in the json file i find only {"error":"invalid_client"}
Can any kind soul out there point me to an error or mistake i am doing?
TIA