Expand my Community achievements bar.

HttpClientRequest POST method with parameters

Avatar

Level 2

Hi all,

I'm using a Javascript activity in a workflow to do a REST API POST call to obtain a taken.

Code is as follows:

var requestUrlAPI = 'https://login.microsoftonline.com/{tenant}/oauth2/token'

var bodyStr = 'grant_type=client_credentials&client_id={clientID}&client_secret={clientSecret}';

var http = new HttpClientRequest(requestUrlAPI);

http.method="POST";

http.header["Content-Type"]= "application/x-www-form-urlencoded";

http.body = bodyStr;

http.execute();

However, I'm getting an error regarding invalid client and client secret. Though it does seem to recognize "grant_type". I've tested the same values in Soap UI with success. Can anyone help deciphering what may be happening here?

Error Code:

HTTP header 'WWW-Authenticate' used for proxy authentication not found.

{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\u000d\u000aTrace ID: 3f12551b-15dc-4c72-964d-c3425f7a2500\u000d\u000aCorrelation ID: fde89e79-a6b4-406e-8387-40480a6a8edd\u000d\u000aTimestamp: 2019-02-07 20:17:02Z","error_codes":[7000215],"timestamp":"2019-02-07 20:17:02Z","trace_id":"3f12551b-15dc-4c72-964d-c3425f7a2500","correlation_id":"fde89e79-a6b4-406e-8387-40480a6a8edd"}

Appreciate any help!

2 Replies

Avatar

Level 1
I am getting the same issue when calling an oauth endpoint. Can someone help?