PUT vs. POST for Uploading Files – RESTful API to be Built Using Zend Framework

There seems to be quite a bit of misunderstanding here. PUT versus POST is not really about replace versus create, but rather about idempotency and resource naming. PUT is an idempotent operation. With it, you give the name of a resource and an entity to place as that resource’s content (possibly with server-generated additions). Crucially, … Read more

Special characters like @ and & in cURL POST data

cURL > 7.18.0 has an option –data-urlencode which solves this problem. Using this, I can simply send a POST request as curl -d name=john –data-urlencode passwd=@31&3*J https://www.example.com Summarizing the comments, in case of mixed “good” and “bad” data and exclamation marks inside we can use on Windows: curl -d “grant_type=client_credentials&client_id=super-client&acr_values=tenant:TNT123” –data-urlencode “client_secret=XxYyZ21D8E&%fhB6kq^mXQDovSZ%Q*!ipINme” https://login.example.com/connect/token

REST API using POST instead of GET

I use POST body for anything non-trivial and line-of-business apps for these reasons: Security – If we use GET with query strings and https, the query strings can be saved in server logs and forwarded as referral links. Both of these are now visible by server/network admins and the next domain the user went to … Read more

How to send file contents as body entity using cURL

I believe you’re looking for the @filename syntax, e.g.: strip new lines curl –data “@/path/to/filename” http://… keep new lines curl –data-binary “@/path/to/filename” http://… curl will strip all newlines from the file. If you want to send the file with newlines intact, use –data-binary in place of –data

How do you post to an iframe?

Depends what you mean by “post data”. You can use the HTML target=”” attribute on a <form /> tag, so it could be as simple as: <form action=”do_stuff.aspx” method=”post” target=”my_iframe”> <input type=”submit” value=”Do Stuff!”> </form> <!– when the form is submitted, the server response will appear in this iframe –> <iframe name=”my_iframe” src=”https://stackoverflow.com/questions/168455/not_submitted_yet.aspx”></iframe> If that’s … Read more