Avoid duplicate POSTs with REST

Another solution that’s been proposed for this is POST Once Exactly (POE), in which the server generates single-use POST URIs that, when used more than once, will cause the server to return a 405 response. The downsides are that 1) the POE draft was allowed to expire without any further progress on standardization, and thus … Read more

REST API DESIGN – Getting a resource through REST with different parameters but same url pattern

In my experience, GET /users/{id} GET /users/email/{email} is the most common approach. I would also expect the methods to return a 404 Not Found if a user doesn’t exist with the provided id or email. I wouldn’t be surprised to see GET /users/id/{id}, either (though in my opinion, it is redundant). Comments on the other … Read more

Get/post to RESTful web service

You’ll need to add a reference to the MSXML library: Dim sUrl As String Dim response As String Dim xmlhttp Set sUrl = “http://my.domain.com/service/operation/param” Set xmlhttp = Server.CreateObject(“MSXML2.ServerXMLHTTP”) xmlhttp.open “POST”, sURL, False xmlhttp.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded” xmlhttp.send() Dim response As String = xmlhttp.responseText Set xmlhttp = Nothing

Swagger UI passing authentication token to API call in header

@ApiImplicitParams and @ApiImplicitParam should do the trick: @GET @Produces(“application/json”) @ApiImplicitParams({ @ApiImplicitParam(name = “Authorization”, value = “Authorization token”, required = true, dataType = “string”, paramType = “header”) }) public String getUser(@PathParam(“username”) String userName) { … } From the documentation: You may wish you describe operation parameters manually. This can be for various reasons, for example: Using … Read more

When in my REST API should I use an envelope? If I use it in one place, should I always use it?

I’d say “hell yes!” (contrary to someone here who said “hell no”) to an envelope! There’s always some extra information that needs to be sent from some endpoints. Pagination, errorMessages, debugMessages for example. An example how facebook does it: Response from get friends request { “data”: [ { “id”: “68370”, “name”: “Magnus” }, { “id”: … Read more

Curl retry mechanism

The following statement will retry 5 times or a maximum of 40 seconds with a connection timeout of 5 seconds, and no exponential backoff policy curl –connect-timeout 5 \ –max-time 10 \ –retry 5 \ –retry-delay 0 \ –retry-max-time 40 \ ‘http://your_url’ –max-time 10 (how long each retry will wait) –retry 5 (it will retry … Read more