84
Views
17
Comments
Consume the Rest API Of Box application and upload the file on it

I am working on the file upload using box endpoints in OutSystems. I have just created the folder using that box endpoint. Now I trying to do a file upload on the folder I have created in the box application. 

  1. Consume rest API and I added the file upload endpoint on it. (using a single method)
  2. In Body, I gave the grant_type, client_id, Client_secret, refresh_token and I gave all the authorization. 
  3. After that, I need to know where to upload the file
  4. Id:(folder id) 

I have run these endpoints in the postman and I successfully uploaded the file in that box folder. 

In outsystems, I don't know where to upload the file. Can anyone help me to solve this issue? and share any OML. It would be a great help for me. 

I have attached my OML for reference. I have used reactive web application.

Sample.oml
2019-01-07 16-04-16
Siya
 
MVP
UserImage.jpg
Sakthipriya B

This box connector supports only the traditional web application only, I am using the reactive web application.

2019-01-07 16-04-16
Siya
 
MVP

There is no box connector for reactive in forge yet. What you could do is build one yourself by referring the traditional one.

UserImage.jpg
Sakthipriya B

Yes, I am just trying to use the endpoints, While trying to build that I got stuck. Can you please help on that @Siya 

2019-01-07 16-04-16
Siya
 
MVP

Do "Add REST API Method" under the existing endpoint with POST andURL as https://upload.box.com/api/2.0/files/content. Paste the following 

--BOUNDARY

Content-Disposition: form-data; name="attributes"

Content-Type: application/json

{"name":"Contract.pdf", "parent":{"id":"11446498"}}

--BOUNDARY

Content-Disposition: form-data; name="file"; filename="Contract.pdf"

Content-Type: application/pdf

[BINARY PDF CONTENT HERE]

--BOUNDARY--

in the request and finish the process. 

You can call this method in your action by passing the filename, id and file content.  This is based on the reference given here for Multipart/form-data

btw I am not sure how to change the Content-Type of the file dynamically. 

UserImage.jpg
Sakthipriya B
2019-01-07 16-04-16
Siya
 
MVP

Please see attached OML. I could not test it as I don't have the parent id. Do set Client ID and Client Secret in Site Properties. 

Sample.oml
UserImage.jpg
Annie Bibiana Yesudass

Hi @Siya ,

             I tried the above oml facing 400 Bad Request Error. Do we also need to configure in OutSytems before using directly using its API.  How to configure in OutSytems ?

2019-01-07 16-04-16
Siya
 
MVP

Before calling the API, you must configure the Site Properties by setting the Client ID and Client Secret. Additionally, you need to specify the parent id on the screen

UserImage.jpg
Annie Bibiana Yesudass

Hi @Siya ,
                  Used the same oml file, I have set Client ID and Client Secret also the parent Id but facing 400 Bad Request Error. I don't what mistake I am doing.



2019-01-07 16-04-16
Siya
 
MVP

Can you share a valid parent id ? Will update you once there is some progress.

UserImage.jpg
Sakthipriya B

Parent ID: 255876114271 

Please find the OML file below

Sample_box_fileupload.oml
2019-01-07 16-04-16
Siya
 
MVP

Could you please check if the Parent ID you've provided is correct ? I get a 404 error when attempting to retrieve information for the specified parent ID.

UserImage.jpg
Sakthipriya B
2019-01-07 16-04-16
Siya
 
MVP

Ok. Please share the equivalent curl command from Postman. You can get it by clicking Code option next to Send button

UserImage.jpg
Sakthipriya B


curl --location --request GET 'https://api.box.com/2.0/folders/255876114271' \--header 'Authorization: Bearer QvKKrGY0Zz1nEVyaXQzgIS8JkBe0Q94M' \--header 'Cookie: box_visitor_id=65fc245c611da8.21780000; site_preference=desktop'

2019-01-07 16-04-16
Siya
 
MVP

The token you have provided is working but the token I have generated using the Client ID and secret key is not working. I have sent you a DM. Please check. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.