REST Client: Error was: HAPI-1861: Failed to parse JSON encoded FHIR content: Unexpected character ('@' (code 64)): expected a valid value

huangapple go评论45阅读模式
英文:

REST Client: Error was: HAPI-1861: Failed to parse JSON encoded FHIR content: Unexpected character ('@' (code 64)): expected a valid value

问题

I am trying to understand FHIR fundamentals and I have installed REST Client in VS code to post the following

Variable declaration

@host = https://hapi.fhir.org/baseR4
@contentType = application/json

Post Patient

@name createPatient

POST {{host}}/Patient HTTP/1.1
content-type: {{contentType}}

{
"resourceType": "Patient",
"name": [
{
"use": "official",
"family": "Vijay",
"given": ["Karthik"]
}
],
"gender": "male",
"birthDate": "1998-02-26",
"telecom":[
{
"value": "9000000000",
"use": "mobile",
"system": "phone"
},
{
"value": "demo@gmail.com",
"system": "email"
}
],
"address": [
{
"line": [
"213, Diamond Residency"
],
"city": "Manipal",
"state": "Karnataka",
"postalCode": "567104"
}
]
}

and it works without any issues

{
"resourceType": "Patient",
"id": "10690049",
"meta": {
"versionId": "1",
"lastUpdated": "2023-06-05T16:56:48.315+00:00",
"source": "#JXAcEJnruLAVvERP"
},
"text": {
"status": "generated",
"div": "<div xmlns="http://www.w3.org/1999/xhtml"><div class="hapiHeaderText">Karthik VIJAY

<table class="hapiPropertyTable">

Address 213, Diamond Residency
Manipal Karnataka Date of birth 26 February 1998

"
},
"name": [
{
"use": "official",
"family": "Vijay",
"given": [
"Karthik"
]
}
],
"telecom": [
{
"system": "phone",
"value": "9000000000",
"use": "mobile"
},
{
"system": "email",
"value": "demo@gmail.com"
}
],
"gender": "male",
"birthDate": "1998-02-26",
"address": [
{
"line": [
"213, Diamond Residency"
],
"city": "Manipal",
"state": "Karnataka",
"postalCode": "567104"
}
]
}

as you see above it returns the valid JSON with the following headers

HTTP/1.1 201 Created
Server: nginx/1.18.0 (Ubuntu)
Date: Mon, 05 Jun 2023 21:53:13 GMT
Content-Type: application/fhir+json;charset=utf-8
Transfer-Encoding: chunked
Connection: close
X-Powered-By: HAPI FHIR 6.7.3-SNAPSHOT/d94627c382/2023-05-18 REST Server (FHIR Server; FHIR 4.0.1/R4)
ETag: W/"1"
X-Request-ID: ReW0SjpvyU7OG0SN
Content-Location: https://hapi.fhir.org/baseR4/Patient/10691862/_history/1
Last-Modified: Mon, 05 Jun 2023 21:53:13 GMT
Location: https://hapi.fhir.org/baseR4/Patient/10691862/_history/1
Content-Encoding: gzip

However, while trying to set the variable like mentioned below

Variable declaration

@host = https://hapi.fhir.org/baseR4
@contentType = application/json

Post Patient

@name createPatient

POST {{host}}/Patient HTTP/1.1
content-type: {{contentType}}

{
"resourceType": "Patient",
"name": [
{
"use" : "official",
"family" : "Vijay",
"given" : ["Karthik"]
}
],
"gender": "male",
"birthDate": "1998-02-26",
"telecom":[
{
"value": "9000000000",
"use": "mobile",
"system": "phone"
},
{
"value": "demo@gmail.com",
"system": "email"
}
],
"address": [
{
"line": [
"213, Diamond Residency"
],
"city": "Manipal",
"state": "Karnataka",
"postalCode": "567104"
}
]
}

@patientId = {{createPatient.response.body.$.id}

it throws the following error

{
"resourceType": "OperationOutcome",
"text": {
"status": "generated",
"div": "<div xmlns="http://www.w3.org/1999/xhtml">

Operation Outcome

<table border="0">

<td style="font-weight: bold;">ERROR [] HAPI-0450: Failed to parse request body as JSON resource. Error was: HAPI-1861: Failed to parse JSON encoded FHIR content: Unexpected character ('@' (code 64)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: UNKNOWN; line: 35, column: 2]