Dear Reader;
in my 1st attempt to connect to a REST server with TIdHTTP all I was told to do is to POST an HTTP request in the form:
"https://www.server.com/api/authentication/oauth2/token?grant_type=password&username=***&password=***&client_id=***&client_secret=***"
with server-side generated username, password, client_id and client_secret:
IdHTTP->ResponseCode==500;
IdLogFile has the following:
Stat Connected.
Sent DateTime: POST /api/authentication/oauth2/token?grant_type=password&username=nome_de_usuário%40someclient.com&password=metellno1&client_id=wqeqweqweqewqwewq&client_secret=qwewqewqewqewqe HTTP/1.1
Content-Type: application/json
Content-Length: 0
Host: www.someserver.com
Accept: text/html,application/xhtml+xml,application/xml,application/json;q=0.9,*/*;q=0.8
User-Agent: Mozilla/3.0 (compatible; Indy Library)
Recv DateTime: HTTP/1.1 500 Server Error
Content-Length: 347
Content-Type: application/json
Strict-Transport-Security: max-age=31536000; includeSubDomains;
Content-Security-Policy: default-src 'self'; font-src *;img-src * data:; script-src *; style-src *;
Referrer-Policy: strict-origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-SL-Proxy: false
X-XSS-Protection: 1; mode=block
Date: DateTime
{
"failure" : "Pipeline execution failed while waiting for output",
"reason" : "Snap errors: {ruuid=<***some guid***>, label=Decode JSON, failure=Failed to read from binary input view, reason=No content to map due to end-of-input, resolution=Please address the reported issue.}",
"resolution" : "Fix the reported errors"
}
JSON at the bottom of IdLogFile is the server Error detailed.
I have no idea what all that is about, so I ran that same request with PostMan ver.9.31 - it came back with no error and new token in its response.
What do I need to change on VCL/Indy side in order to mimic the PostMan's behaviour? Is this information enough to correct the error?
Please help. Thanks in advance. Boba TC.
in my 1st attempt to connect to a REST server with TIdHTTP all I was told to do is to POST an HTTP request in the form:
"https://www.server.com/api/authentication/oauth2/token?grant_type=password&username=***&password=***&client_id=***&client_secret=***"
with server-side generated username, password, client_id and client_secret:
Code:
TIdHTTP *IdHTTP;
TIdSSLIOHandlerSocketOpenSSL *IdSSLIOHandlerSocketOpenSSL1;
TIdLogFile *IdLogFile1;
AnsiString sURL0, sResp;
IdHTTP->IOHandler = IdSSLIOHandlerSocketOpenSSL1;
IdHTTP->Intercept = IdLogFile1;
TStringList *slHttpRspns;
//...
sURL0 = "https://www.someserver.com/api/authentication/oauth2/token?grant_type=password&username=nome_de_usuário%40oldshoes.com&password=metellno1&client_id=wqeqweqwewqwewq&client_secret=qwewqewewqe";
try{
slHttpRspns = new TStringList;
IdLogFile1->Active = true;
sResp = IdHTTP->Post( sURL0, slHttpRspns );
Memo1->Lines->Add( "IdHTTP->ResponseCode="+IntToStr(IdHTTP->ResponseCode) );//500
//if succeeded the server should come back with a token in JSON form
}catch( Exception &e ){
//...
}
IdHTTP->ResponseCode==500;
IdLogFile has the following:
Stat Connected.
Sent DateTime: POST /api/authentication/oauth2/token?grant_type=password&username=nome_de_usuário%40someclient.com&password=metellno1&client_id=wqeqweqweqewqwewq&client_secret=qwewqewqewqewqe HTTP/1.1
Content-Type: application/json
Content-Length: 0
Host: www.someserver.com
Accept: text/html,application/xhtml+xml,application/xml,application/json;q=0.9,*/*;q=0.8
User-Agent: Mozilla/3.0 (compatible; Indy Library)
Recv DateTime: HTTP/1.1 500 Server Error
Content-Length: 347
Content-Type: application/json
Strict-Transport-Security: max-age=31536000; includeSubDomains;
Content-Security-Policy: default-src 'self'; font-src *;img-src * data:; script-src *; style-src *;
Referrer-Policy: strict-origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-SL-Proxy: false
X-XSS-Protection: 1; mode=block
Date: DateTime
{
"failure" : "Pipeline execution failed while waiting for output",
"reason" : "Snap errors: {ruuid=<***some guid***>, label=Decode JSON, failure=Failed to read from binary input view, reason=No content to map due to end-of-input, resolution=Please address the reported issue.}",
"resolution" : "Fix the reported errors"
}
JSON at the bottom of IdLogFile is the server Error detailed.
I have no idea what all that is about, so I ran that same request with PostMan ver.9.31 - it came back with no error and new token in its response.
What do I need to change on VCL/Indy side in order to mimic the PostMan's behaviour? Is this information enough to correct the error?
Please help. Thanks in advance. Boba TC.