Lately I’ve been going hard with Python and Flask to expose a RESTful API for our end users. At this time, it’s only GET methods, no POSTing… until now.
One interesting request that was made to me was to figure out if it was possible to take a GET request, which outputs to JSON and redirects it back into another web service as a POST request.
Think of it like copying data through a web service, if that makes any sense. Or maybe like “GET-redirect data-POST”.
To further drive the point home, I have a simple GET request:
urllib2.Request("http://localhost:5000/request/security/773/20110101")
The output is JSON and I want to take that data and POST it back to:
http://localhost:5000/submit/transaction/773/20110101
Assuming data mapping is one to one (which it is). Is there a way to do that as one call on the server side? Is that even a smart thing to do? Just looking for thoughts, ideas and comments.
Seems simple enough. Why not just do the post from your request/security handler?
If the posting is an optional thing, you could have done a get like:
And then:
In any case for this to be a single round-trip with the server, the server is going to have to do the POST to itself. The client won’t be able to get the results from the GET and then do a POST with 2 round-trips.