cancel
Showing results for 
Search instead for 
Did you mean: 

BOX API connection

ChloeMacIntosh
Level 4
Hi,

I am attempting to connect to BOX application via APIs however am getting this error:
Internal : Unexpected error Failed to get OAuth2.0 Access Token : "Unexpected character encountered while parsing value: <. Path '', line 2, position 1." ""

Is anyone able to advise what may be wrong/how to resolve? 


------------------------------
Chloe MacIntosh
Automation Developer
Zurich Insurance
Europe/London
------------------------------
1 BEST ANSWER

Helpful Answers

Hi @ChloeMacIntosh,

I think the issue here is that the fields "code" and "grant_type" aren't passed along to the Authorization URI when you set the BluePrism authentication type to OAuth 2.0. The default behavior is to send only the the client_id and client_secret.  Also the Authorization URI is different in your BluePrism configuration. However it doesn't matter in this case as it wouldn't work anyways.

I suggest that you set the Authentication to None and Use the "Request Access Token" action (you have already created it) in your Web API to get the access token. Set the Body Template as 
code=
&grant_type=[grant_type]&client_id=[client_id]&client_secret=[client_secret]

Make sure you have set the Header for this action
Content-Type      application/x-www-form-urlencoded

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

View answer in original post

6 REPLIES 6

Rambo27
Level 8
Hi @Chloe MacIntosh,

Its seems if the access token request is invalid, such as the redirect URL didn't match the one used during authorization, then the server needs to return an error response. Error responses are returned with an HTTP 400 status code , with error and error_description parameters.​ 

Please check the token request once there might be some parsing issue or mismatch in path.

Check more on Box API on this reference. 
https://developer.box.com/guides/tooling/postman/quick-start/make-api-call/

------------------------------
Shikhar Mishra
RPA Lead
Infosys Pvt Ltd
Pune,India
------------------------------
Shikhar Mishra RPA Lead Infosys

Hi @Chloe MacIntosh,

I tried creating an Box App with Server Auth. Below are the configurations that worked for me to get the access token using POSTMAN.

28307.png
28308.png
Reference: https://developer.box.com/guides/authentication/client-credentials 

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi @Shikhar Mishra

Thank you for coming back to me. I am able to successfully retrieve Access Token using Postman, however when I have tried to set up in Blue Prism it is throwing the above error message, so I am unsure what has gone wrong as API set up for BOX in Blue Prism seems aligned to Postman inputs. Do you have any experience with this, or guidance you can offer please?
28309.png

------------------------------
Chloe MacIntosh
Automation Developer
Zurich Insurance
Europe/London
------------------------------

Hi @shashank.kumar280
Thank you for coming back to me. I am able to successfully retrieve Access Token using Postman, however when I have tried to set up in Blue Prism it is throwing the above error message, so I am unsure what has gone wrong as API set up for BOX in Blue Prism seems aligned to Postman inputs. Do you have any experience with this, or guidance you can offer please?
28310.pngAttached are some snips of the current API set up in Blue Prism, if this provides better insight.

------------------------------
Chloe MacIntosh
Automation Developer
Zurich Insurance
Europe/London
------------------------------

Hi @ChloeMacIntosh,

I think the issue here is that the fields "code" and "grant_type" aren't passed along to the Authorization URI when you set the BluePrism authentication type to OAuth 2.0. The default behavior is to send only the the client_id and client_secret.  Also the Authorization URI is different in your BluePrism configuration. However it doesn't matter in this case as it wouldn't work anyways.

I suggest that you set the Authentication to None and Use the "Request Access Token" action (you have already created it) in your Web API to get the access token. Set the Body Template as 
code=
&grant_type=[grant_type]&client_id=[client_id]&client_secret=[client_secret]

Make sure you have set the Header for this action
Content-Type      application/x-www-form-urlencoded

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi Shashank, thank you so kindly for your advice! This has resolved initial issues 🙂

------------------------------
Chloe MacIntosh
Automation Developer
Zurich Insurance
Europe/London
------------------------------