失败401量角器中显示未授权的错误

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

我试图自动化在postman工具中生成的响应,但得到错误401 unqutorized错误。尝试通过向授权令牌提供确切的安全令牌来解决许多问题,但它没有成功。

//In this method the security token passed is newly generated and it works fine and produces response 200 in postman tool
    async claimsetResponseOP(SecurityToken:string){
       var options = {
       method: 'POST',
       url: 'http://nhsappchna8086/LMHIAService/api/v3/ValueSet/$expand',
       //Giving header to the request 
       headers: {
              'Authorization-Token': SecurityToken,  // Here is the place where the security token is passed in the headers
               'Accept': 'application/json+fhir',
               'Content-Type' : 'application/json+fhir',
               'Authorization-Type' : 'Native'
              },
              body: {
                 "resourceType ": "Parameters",
                  "parameter": [
                        {
                          "name": "ValueSet",
                          "resource": {
                                "resourceType": "ValueSet",
                                "status": "active",
                                "compose": {
                                "include": [{
                                        "system": "http://snomed.info/sct",
                                        "filter": [{
                                             "property": "constraint",
                                             "op": "=",
                                             "value": "<<(*:R363698007=271629002)"
                                            }
                                        ]
                                    }
                                ]
                              }
                            }
                          }
                        ]
                      },
                      json:true,
                      resolveWithFullResponse: true
                     }; 
//Error gets displayed in below line as Failed 401 unautorized error
                  await requestp(options).then(async function(response){    
                    await  requestp(options).then(async function(Content){
                            if (await response.statusCode == 200){
                                    var info =  Content.body; 
                              }
                            })
                       })
                    }

执行时会显示以下错误:任何人都可以帮助您解决问题

Failed: 401 - {"resourceType":"OperationOutcome","id":"AUTH-01","text":{"status":"additional","div":"Unauthorised"},"issue":        [{"severity":"error","code":"security","details":{"text":"9254 - Unauthorised"}}]}
javascript protractor postman npm-request
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.