Solved

HTTPCaller Transformer using the Post method returns a uninteded result


I used the httpcaller transformer call the Baidu NLP api using the post method. But I have got a uninteded result.

Baidu NLP API: http://ai.baidu.com/docs#/NLP-API/top

Now I use the lexer for example.

Http method: POST

Request url: https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer

Url parameter??Valid for one month?access_token=24.04f6c0626853e9c8b18ffbbaf5a0743b.2592000.1532943274.282335-11467307

Header : Content-Type=application/json

Body:?json,requires gbk encoding?

{

"text":"??????????"

}

If called successfully , it will return a json(encoding in gbk?,just like below.

{ "text":"??????????", "items":[ { "byte_length":4, "byte_offset":0, "formal":"", "item":"??", "ne":"ORG", "pos":"", "uri":"", "loc_details":[ ], "basic_words":["??"] }, { "byte_length":2, "byte_offset":4, "formal":"", "item":"?", "ne":"", "pos":"v", "uri":"", "loc_details":[ ], "basic_words":["?"] }, { "byte_length":4, "byte_offset":6, "formal":"", "item":"??", "ne":"", "pos":"m", "uri":"", "loc_details":[ ], "basic_words":["?","?"] }, { "byte_length":6, "byte_offset":10, "formal":"", "item":"???", "ne":"", "pos":"n", "uri":"", "loc_details":[ ], "basic_words":["?","??"] }, { "byte_length":4, "byte_offset":16, "formal":"", "item":"??", "ne":"", "pos":"n", "uri":"", "loc_details":[ ], "basic_words":["??"] } ] }

Httpcaller parameter:

The return I have got:(It returned a html file instead of a json file.)

I also tried this method on postman. It works pretty well.

I have troubled in this problem for two days. And searched every similar answer in the knowledge center. But I still don't know where the problem is.

Any help is appreciated.

JISHENG LIU

icon

Best answer by takashi 1 July 2018, 07:45

View original

4 replies

Userlevel 2
Badge +17

Hi @liujisheng, I was able to get desired response (JSON) with this setting.

Upload Body (Value of "_result"):

{ "text" : "???????" }

HTTPCaller Parameters:

0684Q00000ArJpuQAF.png

Response Body:

{
   "log_id" : 6729234485593642004,
   "text" : "???????",
   "items" : [
      {
         "loc_details" : [],
         "byte_offset" : 0,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "??",
         "basic_words" : [ "??" ],
         "byte_length" : 6,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 6,
         "uri" : "",
         "pos" : "v",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 9,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "???",
         "basic_words" : [ "?", "??" ],
         "byte_length" : 9,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 18,
         "uri" : "",
         "pos" : "w",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      }
   ]
}

Hi @liujisheng, I was able to get desired response (JSON) with this setting.

Upload Body (Value of "_result"):

{ "text" : "???????" }

HTTPCaller Parameters:

0684Q00000ArJpuQAF.png

Response Body:

{
   "log_id" : 6729234485593642004,
   "text" : "???????",
   "items" : [
      {
         "loc_details" : [],
         "byte_offset" : 0,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "??",
         "basic_words" : [ "??" ],
         "byte_length" : 6,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 6,
         "uri" : "",
         "pos" : "v",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 9,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "???",
         "basic_words" : [ "?", "??" ],
         "byte_length" : 9,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 18,
         "uri" : "",
         "pos" : "w",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      }
   ]
}
Thanks a lot. I have got my desired response (JSON) by follow your suggestion.

 

 

Userlevel 2
Badge +17

Hi @liujisheng, I was able to get desired response (JSON) with this setting.

Upload Body (Value of "_result"):

{ "text" : "???????" }

HTTPCaller Parameters:

0684Q00000ArJpuQAF.png

Response Body:

{
   "log_id" : 6729234485593642004,
   "text" : "???????",
   "items" : [
      {
         "loc_details" : [],
         "byte_offset" : 0,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "??",
         "basic_words" : [ "??" ],
         "byte_length" : 6,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 6,
         "uri" : "",
         "pos" : "v",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 9,
         "uri" : "",
         "pos" : "",
         "ne" : "LOC",
         "item" : "???",
         "basic_words" : [ "?", "??" ],
         "byte_length" : 9,
         "formal" : ""
      },
      {
         "loc_details" : [],
         "byte_offset" : 18,
         "uri" : "",
         "pos" : "w",
         "ne" : "",
         "item" : "?",
         "basic_words" : [ "?" ],
         "byte_length" : 3,
         "formal" : ""
      }
   ]
}
?????????HTML???????????????API?????Header????????Headers???Content-Type: application/json????????????

 

0684Q00000ArM7sQAF.png

?????????HTML???????????????API?????Header????????Headers???Content-Type: application/json????????????

 

 

???????api?????????????????????????????????? ··· ···

Reply