发布到Azure FHIR Server方法无法通过身份验证失败404

问题描述 投票:0回答:1

我有一个已经过POSTMAN测试的Azure FHIR服务器,我能够使用POSTMAN和Oauth令牌读取患者以及POST患者。

我现在创建了一个JavaScript Post方法,以便可以使用自己的方法而不是使用POSTMAN发布数据。我从这里开始遵循基本指南Creating a resource 我可以使用POSTMAN获取访问令牌,并且可以在POST方法中使用该访问令牌。

我的方法和发布数据如下。

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript">

  (async () => {
  const rawResponse = await fetch('https://smarthealth.azurehealthcareapis.com/Patient', {
  method: 'POST',
  Authorization: 'Bearer DGRijc8LrnjCrhRFRSn2Jnf89q2wGT_gxNHtJt',
   headers: {
              'Access-Control-Allow-Origin': '*',
               'Accept': 'application/json',
               'Content-Type': 'application/json',
               'Access-Control-Allow-Origin': 'http://localhost:3000',
               'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS'
                },
    body: JSON.stringify({
    "resourceType": "Patient",
    "id": "9184e31a-a2b3-4b8d-9032-d5377cabaa08",

       "extension": [
         {
          "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
            "extension": [
               {
                "url": "ombCategory",
              "valueCoding": {
               "system": "urn:oid:2.16.840.1.113883.6.238",
             "code": "2106-3",
             "display": "White"
                }
                  },
           {
             "url": "text",
           "valueString": "White"
                         }
                            ]
                        },
                        {
              "url": "http://hl7.org/fhir/StructureDefinition/patient-birthPlace",
        "valueAddress": {
         "city": "Mashpee",
          "state": "Massachusetts",
          "country": "US"
                            }
                        },

                    ],

                    "name": [
                        {
                            "use": "official",
                            "family": "Kutch",
                            "given": [
                                "Sherron"
                            ]
                        }
                    ],

                    "gender": "female",
                    "birthDate": "2009-04-29",

                })
            });
            const content = await rawResponse.json();

            console.log(content);
        })();

    </script>
</head>

<body>
    Javascript Azure FHIR Post Request Test
</body>

</html>

Authentication Failed Image here

javascript azure http post hl7-fhir
1个回答
0
投票

您可以尝试按照以下格式发送请求。

© www.soinside.com 2019 - 2024. All rights reserved.