FHIR Chat · post · javascript

Stream: javascript

Topic: post


view this post on Zulip Brian Postlethwaite (Jun 24 2016 at 07:04):

Just looking for some feedback on if this is the correct way to call a fhir server to get the correct json headers for fhir happening.

                        $.ajax({
                            url: $('#txtPostURL').val() + "/$validate",
                            type: 'POST',
                            contentType: "application/json+fhir",
                            headers: {
                                Authorization: "Bearer " + $('#txtAuthToken').val(),
                                Accept: "application/json+fhir; charset=utf-8"
                            },
                            data: JSON.stringify(parameters)
                            },
                            error: function (ex) {
                                alert(JSON.stringify(ex));
                            }
                        });

In particular its the Accept part in the headers, is this correct (not wanting to use the _format=json on each request)

view this post on Zulip Erich Schulz (Jun 24 2016 at 08:02):

+1 for the question Brian - I'm looking to do this myself in next week or 2 (although I'll be using the node npm "request" package - is there a wiki page somewhere with these basic "hello world" examples?

view this post on Zulip Erich Schulz (Jun 24 2016 at 10:47):

@Brian Postlethwaite i just used chrome to sniff the network calls in clinFHIR when it posts and see this:

POST /baseDstu3/ HTTP/1.1
Host: fhirtest.uhn.ca
Connection: keep-alive
Content-Length: 2054
Accept: application/json, text/plain, */*
Origin: http://107.170.196.80
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://107.170.196.80/resourceCreator.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,en-AU;q=0.6

view this post on Zulip Erich Schulz (Jun 24 2016 at 10:49):

presumable you should be able to just Accept: application/json (?)


Last updated: Apr 12 2022 at 19:14 UTC