Box.com create/update folder from salesforce using api v2 -


I'm trying to create a new folder in the box from a controller class in SalesBox using API version 2. I'm receiving access token and I'm also able to retrieve items from a folder with a HTTP GET request. But I'm not able to create a new folder in the box. Also, the file is not able to copy files from 1 folder to another or update folder information. Below is the code to update the details of my folder:

  html h = new (hp); HttpRequest REQ = new HttpRequest (); String and point value = 'https://api.box.com/2.0/ folders / mam folder_id'; Req.setEndpoint (endPointValue); Req.setHeader ('Authority', 'Bearer' + MacCastoken); Req.setBody ('description =' + encoding Youthil encoding ('new', 'u' code here 'tf-8')); Req.setMethod ('Post'); HttpResponse res = h.send (req); I get the following response: {"type": "error", "status": 400, "code": "bad_request", "context_info": {"errors": [{"reason": "invalid_metmeter", " Name ":" unit-entity "," message ":" invalid value 'description = new'. The unit object should be correctly named nested resource attribute name /} "}", "help_url": "http: / \ /developers.box.com \ / docs \ / # errors "," message ":" bad request "," request_id ":" my request id "} Can anyone help me on this? Thanks in advance! According to the document, the box API expects that the request parameters and request method will be required in the JSN format. Please Keep. Try the following:  
  html h = new (hp); HttpRequest REQ = new HttpRequest (); String and point value = 'https://api.box.com/2.0/ folders / mam folder_id'; Req.setEndpoint (endPointValue); Req.setHeader ('Authority', 'Bearer' + MacCastoken); Req.setBody ('{"Description": "New Folder Details"}'); Req.setMethod ('put'); HttpResponse res = h.send (req);  

PS You were also using the encoding Youthil.inline code () method incorrectly. The first parameter should be a string that you are trying to make URL-safe and the second parameter is encoding (see the documentation)


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -