How do I get parameters from a PUT request?

Asked

Viewed 570 times

1

I am starting to study Web Service and created an example of an API in REST. I am passing parameters via PUT to the API and picking up with the parse_str in PHP but what comes back to me is something completely different...

How do I get the parameters correctly to consume my API?

My code:

case "PUT":
        echo "PUT<br /><br />";

        echo "Inputs:<br/>";
        parse_str(file_get_contents("php://input"),$put_vars);

        echo "<br/>JSON:<br/>";
        echo json_encode($put_vars);

        echo "<br/><br/>Array comum:<br/>";
        print_r($put_vars);
        break;

Response print: inserir a descrição da imagem aqui

  • Form you send is as Multipart/form-date?

  • I’m actually using Postman to do the tests...

  • In Postman have the option to do with Multipart/form-data or send the request as raw. This is the last one you are using?

  • No, I checked here and the form-date option is checked

1 answer

1


You may not use multipart/form-data to send PUT or DELETE Postman have an option to send requests as raw (raw), use this way it should work

Browser other questions tagged

You are not signed in. Login or sign up in order to post.