I am working on a medical application based on HL7 FHIR. I am trying to add new record using XML and JSON both. But all I get is the '500 Internal Server Error'.
The XML I am trying to POST is:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Patient Data</title>
<id>urn:uuid:20</id>
<updated>2015-05-21T16:33:58.030533</updated>
<entry>
<title>Patient Dummy Data</title>
<id>Other/p21-disease-activity-score-1439917023</id>
<updated>2015-08-18T18:57:03</updated>
<published>2015-08-18T18:57:03</published>
<content type="text/xml">
<Other xmlns="http://hl7.org/fhir">
<identifier>
<value value="p21-disease-activity-score-1439917023" />
</identifier>
<text>
<status value="generated" />
</text>
<subject>
<reference value="patient/21" />
<display value="4" />
</subject>
<code>
<coding>
<system value="http://hl7.org/fhir/other-resource-type" />
<code value="RA_DISEASE_ACTIVITY" />
</coding>
</code>
</Other>
</content>
</entry>
</feed>
I am posting this XML to API Server using PHP-CURL but getting 500 Internal Server Error.
I tried with JSON too but no luck. Here is the JSON:
[
{
"resourceType": "Bundle",
"title": "PatientData",
"id": "urn:uuid:21",
"updated": "2015-05-21T16:33:58.030533",
"entry": [
{
"title": "MyTitle",
"id": "Other/p007-shoulder-lt-1439220540",
"updated": "2015-08-10T11:29:00",
"published": "2015-08-10T11:29:00",
"author": {
"name": "Medtak"
},
"content": {
"resourceType": "Other",
"identifier": "007",
"text": {
"status": "generated"
},
"subject": {
"reference": "patient/007",
"display": "true"
},
"code": {
"coding": [
{
"system": "http://hl7.org/fhir/other-resource-type",
"code": "RA_DISEASE_ACTIVITY"
}
]
}
}
}
]
}
]
I have spent almost 3 days to fix this issue but couldn't find any solution. Any help would be appreciated. Thanks!
POST a resource via CURL
curl -X POST https://api.1uphealth.care/fhir/stu2/Patient \
-H "Content-Type: application/json" \
-H "Authorization: Bearer xxx_your_access_token_here_xxx" \
-d '{"resourceType": "Patient","id": "helloiamatestpatient","gender": "female"}'
If you're posting xml, use the correct xml fhir doc and change the Content-Type.
Depending on the FHIR server you're working with, you may not be able to POST resources because many do not support write access yet.
Here's some more information on using oauth to query FHIR - https://1up.health/dev/intro-fhir-api-oauth-query
You can get some idea if you following below link.
http://hl7-fhir.github.io/overview-dev.html
Related
Establishing a connection to an MQTT 3.1.1 endpoint following the description here and
the Operating Devops Commands end up in an invalid json 400 response. Even the example MQTT-Bidirectional gets refused with a 400. So this is why i am posting this question here to get hints what i am currently doing wrong and what i can do to get it right to help others running in the same issue. Here is my curl request:
gd#gd:~/ditto/mosquitto$ curl -X POST 'http://{ditto-url}/devops/piggyback/connectivity?timeout=10000' -u devops:foobar -H 'Content-Type: application/json' -d createMQTT_connection.json
{"status":400,"error":"json.invalid","message":"Failed to parse JSON string 'createMQTT_connection.json'!","description":"Check if the JSON was valid (e.g. on https://jsonlint.com) and if it was in required format."}
The hint to check my json file gives back that my json is valid.
Here is how my json file currently looks like:
{
"targetActorSelection": "/system/sharding/connection",
"headers": {
"aggregate": false
},
"piggybackCommand": {
"type": "connectivity.commands:createConnection",
"connection": {
"id": "mqtt-example-connection-123",
"name": "mmqtt-example-connection-123",
"connectionType": "mqtt",
"connectionStatus": "open",
"failoverEnabled": true,
"uri": "tcp://{mqtt-broker-url}:1883",
"sources": [
{
"addresses": [
"{ditto-url}/#"
],
"authorizationContext": ["nginx:ditto"],
"qos": 0,
"filters": []
}
],
"targets": [
{
"address": "{ditto-url}/{{ thing:id }}",
"topics": [
"_/_/things/twin/events"
],
"authorizationContext": ["nginx:ditto"],
"qos": 0
}
]
}
}
}
Someone got an idea why this json is not valid?
Thanks for the support and hints to solve this issue!
[EDIT]
First of all a "-f" makes more sense for the curl request:
curl -X POST -u devops:foobar 'http://{ditto-url}:8080/devops/piggyback/connectivity?timeout=10000' -f createMQTT_connection_1.json
curl: (22) The requested URL returned error: 400 Bad Request
curl: (6) Could not resolve host: createMQTT_connection_1.json
Second here the update json (with the result shown above)
{
"targetActorSelection": "/system/sharding/connection",
"headers": {
"aggregate": false
},
"piggybackCommand": {
"type": "connectivity.commands:createConnection",
"connection": {
"id": "mqtt-example-connection-123",
"connectionType": "mqtt",
"connectionStatus": "open",
"failoverEnabled": true,
"uri": "tcp://{MQTT-Broker-url}:1883",
"sources": [{
"addresses": ["ditto-tutorial/#"],
"authorizationContext": ["nginx:ditto"],
"qos": 0,
"filters": []
}],
"targets": [{
"address": "ditto-tutorial/{{ thing:id }}",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
],
"authorizationContext": ["nginx:ditto"],
"qos": 0
}]
}
}
}
I think the problem you face is curl related.
Please have a look here on how to send json data from a file: https://stackoverflow.com/a/18614411/5058051
Seems the # is missing in your case when specifying the file location.
I have tried to rename the folder with this PATCH API
this is request body :
{
"jsonApi": {
"version": "1.0"
},
"data": {
"id": "urn:adsk.wipprod:fs.folder:co.ZjOwQVYaQbewrWmwN9gBOg",
"type": "folders",
"attributes": {
"name": "folder_new_name_3"
}
}
}
and this is the response :
{
"jsonapi": {
"version": "1.0"
},
"errors": [
{
"id": "c6b15305-2522-4d66-8ebc-11e864ae54fa",
"status": "400",
"code": "BAD_INPUT",
"title": "One or more input values in the request were bad",
"detail": "Delete and Restore of BIM 360 folders are currently disabled for 3rd party applications."
}
]
}.
What I'm doing wrong ? Am I missing something ?
Is this patch Api the correct one to use for renaming folders in BIM 360 Docs ?
You are correct using this approach to rename a folder but it has been enabled lately only:
curl -X PATCH -H "Authorization: Bearer yxz"
"https://developer.api.autodesk.com/data/v1/projects/a.project.id.xyz/folders/urn%3Aadsk.wipprod%3Adm.folder%3AhC6k4hndRWaeIVhIjvHu8w"
-d '{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:dm.folder:hC6k4hndRWaeIVhIjvHu8w",
"attributes": {
"name": "Plans"
}
}
}'
You can now delete a folder as well, like this, but note it is a soft delete vs a hard delete. This is way we use PATCH vs DELETE.
curl -X PATCH -H "Authorization: Bearer yyz"
"https://developer.api.autodesk.com/data/v1/projects/b.project.id.xyz/folders/urn%3Aadsk.wipprod%3Adm.folder%3AhC6k4hndRWaeIVhIjvHu8w"
-d '{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:dm.folder:hC6k4hndRWaeIVhIjvHu8w",
"attributes": {
"hidden": true
}
}
}'
Unfortunately PATCH for Rename on BIM 360 Docs is not supported at the moment. There is work being done on it so it becomes available in the future. Sorry for the bad news.
how can I avoid the parsing errors for
curl -H 'Accept: application/vnd.github.VERSION.raw' -XPUT -g 'https://api.github.com/repos/USER/l1/contents/PATH/FILENAME.json?ref=gh-pages&access_token=57eef6413b12cb439b837b8fc4751b3291650de1' -d '{
"message": "update from api",
"committer": {
"name": "USER",
"email": "USERe#MAIL.com"
},
"content": "[{"a": "aaa","b": "bbb"}]",
"sha": "c321fe9f6418053ecb87eb3cd2518a4xdfc83ebf"
}'
Answer:
{
"message": "**Problems parsing JSON**",
"documentation_url": "https://developer.github.com/v3/repos/contents/"
}
Instead of
"[{"a": "aaa","b": "bbb"}]"
I've tried
"[{\"a\": \"aaa",\"b\": \"bbb\"}]"
but then I get the following error:
{
"message": "**content is not valid Base64**",
"documentation_url": "https://developer.github.com/v3/repos/contents/"
}
Best,
If you open the URL to the documentation given in the error response, you'll see that the content needs to be Base64 encoded.
Would like to know how to authenticate to (for example):
http://www.example.com:8080/openam/UI/Login?realm=CUR&module=CURAuthn
preferably by POSTing JSON via REST over /json/authenticate.
I'm guessing it would be http://www.example.com:8080/openam/UI/Login?realm=CUR&authIndexType=module&authIndexValue=CURAuthn correct?
In any case this module doesn't take the standard X-OpenAM-Username or X-OpenAM-Password headers.
It takes a bunch of custom fields, called ID tokens. For instance it uses IDToken1, IDToken2, IDToken3, ...
How should I go about submitting the tokens to this plugin using the json authentication service? Thanks
All this is explained in the OpenAM's Developer's Guide section 3.4.
The REST URL for your custom module would be:
http://www.example.com:8080/openam/json/authenticate?authIndexType=module&authIndexValue=CURAuthn
If you module doesn't use the standard username/password credentials you'll have to pass your credentials in the request body as JSON.
You would start by sending a empty POST request to OpenAM:
$ curl \
--request POST \
--header "Content-Type: application/json" \
http://www.example.com:8080/openam/json/authenticate?authIndexType=module&authIndexValue=CURAuthn
You should get a response similar to this (based on your custom callbacks):
{
"authId": "eyAid...GDYaEQ",
"template": "",
"stage": "Module11",
"header": "Using CURAuthn",
"callbacks": [
{
"type": "NameCallback",
"output": [
{
"name": "prompt",
"value": "FirstCallback"
}
],
"input": [
{
"name": "IDToken1",
"value": ""
}
]
},
{
"type": "NameCallback",
"output": [
{
"name": "prompt",
"value": "SecondCallback"
}
],
"input": [
{
"name": "IDToken2",
"value": ""
}
]
},
//More callbacks here
]
}
After that just collect the credentials from the user input, fill in the empty values and submit the JSON payload back to the same URL. Make sure you use the same "authId" throughout the authentication process.
I wrote a blog post about custom authentication chains and how to communicate with them via REST. Take a look, it might be helpful.
I'm trying to make a custom YQL table to access a user's likes through the Tumblr API. I made the following table in the YQL editor and saved it as tumblr.likes:
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>nonphoto</author>
<documentationURL>http://www.tumblr.com/docs/api</documentationURL>
<sampleQuery>select * from {table} where username='XXX' api_key='XXX'</sampleQuery>
</meta>
<bindings>
<select itemPath="response.liked_posts" produces="JSON">
<urls>
<url>http://api.tumblr.com/v2/blog/{username}.tumblr.com/likes</url>
</urls>
<inputs>
<key id="username" type="xs:string" paramType="path" required="true" />
<key id="api_key" type="xs:string" paramType="query" required="true" />
</inputs>
</select>
</bindings>
</table>
If this is correct then I should be able to type this query into the YQL console and get a JSON response back from Tumblr:
use "XXX" as tumblr.likes;
select * from tumblr.likes where username='XXX' and api_key='XXX';
But null appears in the results entry of the response, even if debug and diagnostics are checked to prevent caching. The response even shows the correct URL, which works if I just copy and paste it into my browser. Am I missing something? Here's an example response:
{
"query": {
"count": 0,
"created": "2016-01-15T21:44:36Z",
"lang": "en-US",
"diagnostics": {
"url": [
{
"execution-start-time": "2",
"execution-stop-time": "8",
"execution-time": "6",
"id": "579e13ad-a7c3-4eea-81d9-41fda5caf243",
"content": "http://sherpa-bcp5903.dht.yahoo.com:4080/YDHTWebService/V1/get/yql.global/store%3A%2F%2FoSSGByQMlFLQhMqNCwUcp1"
},
{
"execution-start-time": "14",
"execution-stop-time": "1137",
"execution-time": "1123",
"id": "ffab25db-521f-4795-9220-a82e2ac33a9d",
"content": "http://api.tumblr.com/v2/blog/XXX.tumblr.com/likes?api_key=XXX"
}
],
"publiclyCallable": "true",
"user-time": "1146",
"service-time": "1129",
"build-version": "0.2.942"
},
"results": null
}
}