Skip to main content Stream TDX Bengaluru on Salesforce+. Start learning the critical skills you need to build and deploy trusted autonomous agents with Agentforce. Register for free.
error

We made a wrong turn. Try again.

public void CreateFolder(){

//BoxFolder folder = new BoxFolder('bbwh00nt6dylw1w8y1z7p0dnm4zd2m8n', '"Parent": {"id":"0"}');

HttpRequest request=new HttpRequest();

request.setendpoint('https://api.box.com/2.0/folders');

request.setmethod('POST');

request.setHeader('Authorization','Bearer ' + AccessToken);

string body= '{"name":"test", "parent": {"id": "0"}}';

request.setBody(body);

Http p=new Http();

HttpResponse response=p.send(request);

jsonFolderResponse=response.getBody();

System.debug('jsonFolderResponse'+jsonFolderResponse);

}

Hi am getting the following error can any one help out.

16:56:12:643 USER_DEBUG [49]|DEBUG|jsonFolderResponse{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"invalid_parameter","name":"entity-body","message":"Invalid value '{\"name\":\"Test\",\"Parent\":\" {\"id\":\"0\"}\"}'. Entity body should be a correctly nested resource attribute name\/value pair"}]},"help_url":"http:\/\/developers.box.com\/docs\/⌗errors","message":"Bad Request","request_id":"62736846156efda548b4e5"}

Thanks,

Ram
22 answers
  1. Sep 6, 2018, 11:46 AM
    Hi  Board, 

    HttpRequest req = new HttpRequest();

    Http h=new Http();

    String jsonData = '{"parents":[{"id":"root"}],"name":"DynamictTestWNF", "mimeType":"application/vnd.google-apps.folder"}';

    req.setBody(jsonData);

    req.setMethod('POST');

    req.setEndpoint('https://www.googleapis.com/drive/v3/files');

    req.setHeader('Content-length', String.valueOf(jsonData.length()));

    req.setHeader('Content-type', 'application/json');

    req.setHeader('Authorization', 'Bearer '+accessToken);

    HttpResponse res = h.send(req);

    System.debug('Response:- '+res.getBody());

    We need to replace Id "0" to "root". So please put the "root" in JSON Body and check it.

    Thanks,

    Shailendra
0/9000