Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Uploading to DropBox, Could not decode input as JSON.


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Jader Moraes

Posts: 13
Registered: 12/25/16
Uploading to DropBox, Could not decode input as JSON.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 31, 2017 6:24 AM
I'm Trying to upload a File to Dropbox, but a get an error because one of the headers it's a Json String.

here's the whole code:


if upload then
      begin
        req.Params.Clear;
        req.ClearBody;
 
        req.Client.BaseURL := 'https://content.dropboxapi.com';
        req.Resource := '/2/files/upload';
        req.Method := TRESTRequestMethod.rmPOST;
 
 
        with req.Params.AddItem do
        begin
          name := 'Dropbox-API-Arg';
          Kind := pkHTTPHEADER;
          ContentType := ctAPPLICATION_JSON;
          Value :=  params;
        end;
 
        upload_stream.Position := 0;
 
        req.Params.AddUrlSegment('Content-Length', IntTostr(upload_stream.Size));
 
        upload_stream.Position := 0;
 
 
        req.AddBody(upload_stream, ctAPPLICATION_OCTET_STREAM);
 
        req.Params.AddUrlSegment('Content-Type', 'application/octet-stream');
 
 
        RESTClient1.ContentType := 'application/octet-stream';
 
      end;
 
      RESTClient1.Authenticator := Auth2;
      Auth2.Authenticate(req);
      try
        req.Execute;
      except
        on e:Exception do
          ShowMessage(e.Message);
 
      end;
 


the "params"variable content is '{"path":"\test\test.rar"}';

the reponse content is : 'HTTP header "Dropbox-API-Arg": could not decode input as JSON'

what's wrong?

Thanks.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02