Question

Web Request Node & Content-Type application/x-www-form-urlencoded Header in Automator


Badge

I am attempting to request an access token via Microsoft’s Graph API with the Web Request node in Automator and it’s failing saying that I am missing the “grant_type” parameter. I have already verified the (near) exact config works from a PowerShell Invoke-WebRequest command. Does anyone have any ideas? I’ve attached my config and the “Test Web Request” output/response.

 

 

{  "error": "invalid_request",  "error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: \r\nCorrelation ID: \r\nTimestamp: 2023-03-02 20:56:54Z",  "error_codes": [    900144  ],  "timestamp": "2023-03-02 20:56:54Z",  "trace_id":  ,  "error_uri": "https://login.microsoftonline.com/error?code=900144"}


10 replies

Userlevel 6
Badge +10

Looks like you need to sort out the authentication..

Authentication type “basic”

Then you’ll need your ID you are using, (we use a service account in the system and use the API Key from that.)

Password can be just ‘X’

Also you have not selected an orchestration server, have you set this up? - https://support.freshservice.com/en/support/solutions/articles/50000003259-setting-up-the-orchestration-server

 

Userlevel 2
Badge +4

 

I am attempting to request an access token via Microsoft’s Graph API with the Web Request node in Automator and it’s failing saying that I am missing the “grant_type” parameter. I have already verified the (near) exact config works from a PowerShell Invoke-WebRequest command. Does anyone have any ideas? I’ve attached my config and the “Test Web Request” output/response.

 

 

{  "error": "invalid_request",  "error_description": "AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: \r\nCorrelation ID: \r\nTimestamp: 2023-03-02 20:56:54Z",  "error_codes": [    900144  ],  "timestamp": "2023-03-02 20:56:54Z",  "trace_id":  ,  "error_uri": "https://login.microsoftonline.com/error?code=900144"}

I too am also having frustrating issues with this - did you ever find the solution?

I’m able to get a token in Postman with these identical settings in Postman (ID values redacted), but get the same error as Celliott with the following settings in a Web Request node:

 

 

 

Looks like you need to sort out the authentication..

Authentication type “basic”

Then you’ll need your ID you are using, (we use a service account in the system and use the API Key from that.)

Password can be just ‘X’

Also you have not selected an orchestration server, have you set this up? - https://support.freshservice.com/en/support/solutions/articles/50000003259-setting-up-the-orchestration-server

 

For the API key you’re referring to, that seems to be the Freshservice API key - I didn’t think that would be needed in this case, as we’re calling an external API? As for authentication in getting an access token, I think that’s handled by the Application ClientID and Secret.

Also, does it absolutely need an Orchestration server? We get the response errors fine, so in theory we could get any successful response, but I could be wrong!

Cody

Userlevel 2
Badge +4

Ahh this may be the issue for us:
 

seems FS doesn’t support application/x-www-form-urlencoded, hope this will be implemented soon.

The Web Request body text box mentions entering JSON data, which supports what SuperDOS writes.

Badge +2

@cody.pieper do you know if there is a way to convert from application/x-www-form-urlencoded to JSON?

Userlevel 2
Badge +4

@cody.pieper do you know if there is a way to convert from application/x-www-form-urlencoded to JSON?

In Freshservice, I don’t think so unfortunately.

You can of course get application/x-www-form-urlencoded to JSON in terms of data, it’s just a different format. The problem is that if you need to send a web request using a application/x-www-form-urlencoded body, it will still try to use JSON, even if you use a header ‘Content-Type’ = application/x-www-form-urlencoded.

Touch wood it’s implemented in the future!

Userlevel 3
Badge +3

Any news on this? I also need it to access the Graph API.

Userlevel 5
Badge +5

Hi @celliott and @pproost 

Microsoft Graph API calls the requires the parameters to be sent in urlencoded format, while FreshService body requires to be in JSON format. As of now, we support only JSON content-type parameters in the Web Request node, and we don't support if the URL is in an encoded format.

However, we do have a feature request for this and it would be available in our future releases. I apologize for not being of much help right now!

Cheers and Happy Holidays!😊

Badge

@Ammar KB I see you replied regarding the lack of application/x-www-form-urlencoded support in automation Web Request. Do you know if the work to add this feature has been scheduled for development? Thanks

Hi @Ammar KB,

 

Same question as Ben. Is there any information on the feature request being worked on already as it is quite important for us.

 

Thank you

Hi @Ammar KB,

After spending far too much time trying to figure out why our http post wasn’t working, I came across this thread as well.  A formal update on this issue or feature request would be appreciated so we can appropriately decide to wait or plan a workaround for MS graph api authorization.

 

Reply