cancel
Showing results for 
Search instead for 
Did you mean: 

WEB API error-Grant type should be present in Body

HarshWardhan
Level 2
Hi People..i have one query..while working on web api ....i am working on authentication for getting bearer token but i am getting this error "error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'. I have tried everything..included grant-type in body still i  am getting this. can you please help me or guide me where i can be wrong? 🙂

------------------------------
Harsh Wardhan
Rpa Developer
Tcs
Asia/Kolkata
------------------------------
4 REPLIES 4

Hi Harsh,

There are couple of issues i see in your API. 
Part 1 : In your second screen shot you've used template as [grant_type] = "client_credentials". Since the [grant_type] is within square brackets, blue will replace this value with the parameter you passed. ergo : if parameter = abc, then the template will format it to abc = "client_credentials".

Part 2: It looks like you are using Azure AD or Microsoft Online to authenticate. The authentication model you are attempting looks like OAuth2.
This means, grant_type = client_credentials may not fully work. You might want to check out the Sharepoint ACS authentication skill that uses client_credential model. This can help you format your api better. I still doubt if the client_credential model will work well for you at all even if you format the api correctly. On the other hand, you might want to consider the Azure AD authentication skill in DX to try alternate models in OAuth2.

Using skills will help you avoid building this for yourself altogether.

------------------------------
Bimal Sebastian
Consultant
Blueprism
Asia/Kolkata
------------------------------

Hi Bimal 

Thanks for replying-Just one query do we have any video tutorials of WEB API creation which we can refer to? 🙂

------------------------------
Harsh Wardhan
------------------------------

Hi Harsh,

You may refer this video for learning more about Web API. Listen on from the 10th min.
https://digitalexchange.blueprism.com/site/global/developer/learn.gsp

However, i would say authentication is slightly more complex and will require you to learn general authentication models in general. Understanding OAuth2 is detail, specifically the server to server authentication is a good idea for building out web apis. Be watchful, that general OAuth2 models have the 3 step authentication process and these are not meant for RPA. You will have to use the Server to Server or 2 step auth model.

------------------------------
Bimal Sebastian
Consultant
Blueprism
Asia/Kolkata
------------------------------

YaizaGonzalez
Level 2
Could you solved it ? I'm Having the same problem

------------------------------
Yaiza Gonzalez
------------------------------