Assuming the position of the API tester of https://imgur.com/ , Im testing the PUT request to change account settings. I am following this api doc Link for above https://apidocs.imgur.com/#7bc88d39-d06d-4661-afff-38ea5b9a1d0a
Steps to check this
2. Set the Access token 3. Click on send the response for this is 200 as shown below
Expected: To have show_mature and newsletter_subscribed values set to true Actual: show_mature and newsletter_subscribed values are false
Would be really appreciated if someone could let me know why this is happening? Thanks
From the Imgur API docs...
Need help?
The Imgur engineers are always around answering questions. The quickest way to get help is by posting your question on StackOverflow with the Imgur tag.
Real helpful Imgur 🙄.
Answering here to provide a canonical answer in the imgur tag for this nonsense.
All the API examples in the documentation use some form of multipart/form-data
request body payloads. Eg
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{accessToken}}");
var formdata = new FormData();
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://api.imgur.com/3/account/{{username}}/settings", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
and
curl --location --request POST 'https://api.imgur.com/oauth2/token' \
--form 'refresh_token="{{refreshToken}}"' \
--form 'client_id="{{clientId}}"' \
--form 'client_secret="{{clientSecret}}"' \
--form 'grant_type="refresh_token"'
With the exception of any upload related endpoints, this is ABSOLUTELY INCORRECT. Passing data as multipart/form-data
requires the API to handle that request content-type and guess what, the Imgur API does not.
What they do accept is application/x-www-form-urlencoded
.
x-www-form-urlencoded
option, not form-data
-d
option, not --form