I’m building a web application that interfaces with another department’s search site. The idea is that the user will begin to type a term they wish to search for on our website – for instance, “bread”. They’ll get an AJAX-y, autocomplete list of all the possible terms from this other department’s site that include “bread”. After selecting a term, they’ll be redirected to http://other-site.com/, and the results from searching for their selected term will be displayed.
The issue is that I can’t simply redirect to http://other-site.com/?term={whatever-term-they-selected}. According to the API specs I’ve been given, I have to redirect the user to the root URL, http://other-site.com/, with some meta-data about the search term as JSON in the request body. Is this even possible? I can redirect the user to http://other-site.com/ via a header, but that won’t include the data in the request body. I can submit a form pointing to http://other-site.com/, but then the body won’t be raw JSON – it’ll be form data.
I think I need to ask the other department to change their API, but I want to make sure of this before I do.
To answer the question – no, it is not possible for a browser to issue and follow a GET request to another domain with a JSON-body. The other site had to change their API.