Question

2
Replies
22
Views
Anand Kumar Singh (ANANDSINGH)
British Telecom

British Telecom
GB
ANANDSINGH Member since 2010 4 posts
British Telecom
Posted: April 30, 2021
Last activity: May 2, 2021
Posted: 30 Apr 2021 14:27 EDT
Last activity: 2 May 2021 21:51 EDT
Solved

Issue retrieving shared link from BOX as Pega resets content-type as multipart message instead of application/json

We are retrieving the Shared Link from Box for a previously uploaded file via a REST call PUT method

Reference for BOX API Specification Link:Update file - API Reference - Box Developer Documentation

Box API details:  https://api.box.com/2.0/files/:file_id/

Method Used: PUT (via a DataPage in Pega)

Issue: Pega treats the outbound request call as a multi-part message instead of application json, as a result of which BOX response doesnt include the shared link.

When we make the same call by running the Data page manually standalone, the same issue is not replicable and everything works absolutely fine, i.e. shared link is received as expected by the same REST Connector call. But when we make the same Datapage call from within our workflow action, Pega treats this as multi-part message, which is when BOX doesnt return the shared link.

Need Help from experts from Pega/Community to answer if we have any config issue in our code or Pega product issue that is causing this behavior.

Response from our BOX SME whom we consulted on same (Summary):

 The Content-Type of the request when creating the shared link is being incorrectly set by PEGA. PEGA first correctly sets the Content-Type as "application/json", however, then constructs a multipart message which changes the Content-Type to "multipart/form-data". This causes Box to not change anything, aka not create a shared link and therefore not return a shared link in the response.

We are retrieving the Shared Link from Box for a previously uploaded file via a REST call PUT method

Reference for BOX API Specification Link:Update file - API Reference - Box Developer Documentation

Box API details:  https://api.box.com/2.0/files/:file_id/

Method Used: PUT (via a DataPage in Pega)

Issue: Pega treats the outbound request call as a multi-part message instead of application json, as a result of which BOX response doesnt include the shared link.

When we make the same call by running the Data page manually standalone, the same issue is not replicable and everything works absolutely fine, i.e. shared link is received as expected by the same REST Connector call. But when we make the same Datapage call from within our workflow action, Pega treats this as multi-part message, which is when BOX doesnt return the shared link.

Need Help from experts from Pega/Community to answer if we have any config issue in our code or Pega product issue that is causing this behavior.

Response from our BOX SME whom we consulted on same (Summary):

 The Content-Type of the request when creating the shared link is being incorrectly set by PEGA. PEGA first correctly sets the Content-Type as "application/json", however, then constructs a multipart message which changes the Content-Type to "multipart/form-data". This causes Box to not change anything, aka not create a shared link and therefore not return a shared link in the response.

Example call (in terminal window) if trying to use multipart/form-data:

curl -i -X PUT "https://api.box.com/2.0/files/FILEID" -H "Authorization: Bearer TOKEN" -H "Content-Type: multipart/form-data" -d '{"shared_link": {"access": "collaborators"}​​​​​​​}​​​​​​​'

Response from example call (shared link remains null):

{​​​​​​​"type":"file","id":"8067865675076","file_version":{​​​​​​​"type":"file_version","id":"8067865675076","sha1":"efghrty98765678987685ed5975d0ca1e56fa300"}​​​​​​​,"sequence_id":"4","etag":"4","sha1":"efghrty98765678987685ed5975d0ca1e56fa300","name":"Project Proposal.docx","description":"","size":99241,"path_collection":{​​​​​​​"total_count":2,"entries":[{​​​​​​​"type":"folder","id":"0","sequence_id":null,"etag":null,"name":"All Files"}​​​​​​​,{​​​​​​​"type":"folder","id":"456786567876","sequence_id":"0","etag":"0","name":"Top Secret Finance"}​​​​​​​]}​​​​​​​,"created_at":"2021-04-23T03:34:01-07:00","modified_at":"2021-04-23T03:34:01-07:00","trashed_at":null,"purged_at":null,"content_created_at":"2019-10-11T06:43:02-07:00","content_modified_at":"2019-10-11T06:43:02-07:00","created_by":{​​​​​​​"type":"user","id":"576576576765","name":"Box Admin","login":"FooFoo+admin@boxdemo.com"}​​​​​​​,"modified_by":{​​​​​​​"type":"user","id":"576576576765","name":"Box Admin","login":"FooFoo+admin@boxdemo.com"}​​​​​​​,"owned_by":{​​​​​​​"type":"user","id":"576576576765","name":"Box Admin","login":"FooFoo+admin@boxdemo.com"}​​​​​​​,"shared_link":null,"parent":{​​​​​​​"type":"folder","id":"456786567876","sequence_id":"0","etag":"0","name":"Test Folder"}​​​​​​​,"item_status":"active"}​​​​​​​

 

This means that BOX SME proved that if the request content-type is multi-part, the shared link will not be returned as part of response. Need Help from experts from Pega/Community to answer if we have any config issue in our code or Pega product issue that is causing this behavior, i.e. Pega changes content-type to multi-part instead of application/json when the Datapage to call BOX API is made from within workflow action.  

Pega Platform 8.4.4 Data Integration Communications and Media