cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Request body could not decode input as JSON

Helpful | Level 5

Hello!

The follow code (qt c++)

QUrl url;
    url.setScheme("https");
    url.setHost("api.dropboxapi.com");
    url.setPath("/2/file_requests/list_v2");

    QUrlQuery params;
    params.addQueryItem("limit", "1000");
    QByteArray qb_params;
    qb_params.append(params.toString(QUrl::FullyEncoded));

    if(checkUrl(url)){
        QNetworkRequest request;    // 
        request.setUrl(url);

        QByteArray auth;
        auth.append(OAuth_);
        auth.prepend("Bearer ");
        request.setRawHeader("Authorization", auth);
        request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");

        manager->post(request, qb_params);      // 
    }

got an error:

"Error transferring https://api.dropboxapi.com/2/file_requests/list_v2 - server replied: Bad Request"
"Error in call to API function \"file_requests/list:2\": request body: could not decode input as JSON"

What's wrong?

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Request body could not decode input as JSON

Super Collaborator | Level 20

Hi @AndreyStrukov,

Can you clarify, what you really ask? In the error message is clearly stated: "could not decode input as JSON"!

If you take a look on list_v2 documentation, can be seen that parameters have to be in JSON format. Where you encode your parameter ("limit") in JSON? Instead, you use 'QUrlQuery' class, which functionality mimics classic HTML form encoding (not JSON)!

Hope this gives some direction.

View solution in original post

2 Replies 2
Highlighted

Re: Request body could not decode input as JSON

Super Collaborator | Level 20

Hi @AndreyStrukov,

Can you clarify, what you really ask? In the error message is clearly stated: "could not decode input as JSON"!

If you take a look on list_v2 documentation, can be seen that parameters have to be in JSON format. Where you encode your parameter ("limit") in JSON? Instead, you use 'QUrlQuery' class, which functionality mimics classic HTML form encoding (not JSON)!

Hope this gives some direction.

View solution in original post

Highlighted

Re: Request body could not decode input as JSON

Helpful | Level 5

Thank you, got it!

I've fixed it and now it works.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?