Using HTTPS with REST in Java

When you say “is there an easier way to… trust this cert”, that’s exactly what you’re doing by adding the cert to your Java trust store. And this is very, very easy to do, and there’s nothing you need to do within your client app to get that trust store recognized or utilized. On your … Read more

HTTP PATCH support in browsers

HTTP/1.1 did not define the PATCH method. HTTP/1.1 does leave itself open for clients and/or servers to add new methods. RFC 5789 defined the conventions for using the PATCH method. The method defined within a HTTP request is nothing more than a string. Browsers should allow JavaScript to use whatever HTTP method it wants in … Read more

Are these the main differences between RestSharp and ServiceStack’s Client Code? [closed]

As the project lead of ServiceStack I can list some features of the ServiceStack Service clients: The ServiceStack Service Clients are opinionated in consuming ServiceStack web services and its conventions. i.e. They have built-in support for structured validation and error handling as well as all clients implement the same interface so you can have the … Read more

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

Yes, an envelope can be a good idea! 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”: “726497”, “name”: “Leon” }, { “id”: “57034”, … Read more

How can I return json from my WCF rest service (.NET 4), using Json.Net, without it being a string, wrapped in quotes?

I finally figured out a solution to this. It’s not what I would have preferred (which would be to return the specific object type, and somehow instruct WCF to use a Json.Net serializer, instead of the DataContractJsonSerializer), but it is working great, and it’s simple and clear. Extending my contrived example using this new solution: … Read more

Reading JSON from SimpleHTTPServer Post data

Thanks matthewatabet for the klein idea. I figured a way to implement it using BaseHTTPHandler. The code below. from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import SocketServer import simplejson import random class S(BaseHTTPRequestHandler): def _set_headers(self): self.send_response(200) self.send_header(‘Content-type’, ‘text/html’) self.end_headers() def do_GET(self): self._set_headers() f = open(“index.html”, “r”) self.wfile.write(f.read()) def do_HEAD(self): self._set_headers() def do_POST(self): self._set_headers() print “in post method” … Read more

Flutter fetched Japanese character from server decoded wrong

If you look in postman, you will probably see that the Content-Type http header sent by the server is missing the encoding tag. This causes the Dart http client to decode the body as Latin-1 instead of utf-8. There’s a simple workaround: http.Response response = await http.get(‘SOME URL’,headers: {‘Content-Type’: ‘application/json’}); List<dynamic> responseJson = json.decode(utf8.decode(response.bodyBytes));

Logging request and response in one place with JAX-RS

You can create filters and easily bind them to the endpoints you need to log, keeping your endpoints lean and focused on the business logic. Defining a name binding annotation To bind filters to your REST endpoints, JAX-RS provides the meta-annotation @NameBinding and it can be used as following: @NameBinding @Retention(RUNTIME) @Target({TYPE, METHOD}) public @interface … Read more