0

I am trying to update my json list on https://app.jsonstorage.net/

but i got response code 415 here is my code:

enter image description here

and this is my json on jsonstorage:

[{"username": "Amirhossein", "password": "302940101692", "email": "[email protected]", "phone": "09944236807"},{"username": "Hosna", "password": "74610945", "email": "[email protected]", "phone": "09353792083"}]

2 Answers 2

1

Try to add a header to your request:

Response resPut = await put (postur1, 
    body: jsonEncode(<String, String>{
        "username": username,
        "password": password,
        "email": email,
        "phone": phone
        },
    headers: {
          "Accept": "application/json",
          "content-type": "application/json"
        }
    )
);
Sign up to request clarification or add additional context in comments.

Comments

0

The code 415 means "Unsupported Media Type", and if you're getting that back it means you're successfully sending a put request to that URL, but with the wrong content type. Adding the following headers should resolve the issue:

Response resPut = await put(postUrl, 
    body: jsonEncode(<String, String>{
        "username": username,
        "password": password,
        "email": email,
        "phone": phone,
    },
    headers: {
        "Accept": "application/json",
        "content-type": "application/json",
    },
));

If the error still occurs, I suggest that you read the documentation of the API you are consuming to see what you need to send.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.