API REST with LI 14.0
Posted: Tue Jun 08, 2021 10:54 pm
Hy all,
i need to consume an REST API from EDM environnement. i have make the request on SOAP-ui and it works well, the document name was changed, but i do not have success with LI :
Command : ERROR "Erreur de réception de la réponse HTTP"
{"message":"[HttpMessageNotReadableException] Could not read JSON document: Unrecognized token 'clearCriterionList': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (PushbackInputStream); line: 1, column: 20]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'clearCriterionList': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (PushbackInputStream); line: 1, column: 20]"}
On SOAP-UI I used this URL :
http://servrged1/serviceweb/rest/api/us ... main/<parm 1>/base/<parm 2/document/<parm 3>/tag?clearCriterionList=false
"parm 1" is an identifiant of domains to work
"parm 2" is an identifiant of database to access
"parm 3" is the document id
I need also tha have in the body
{"criterionList": [{"categoryId": 38,"word": "ANNULE"},{"categoryId": 39,"word": " "},{"categoryId": 40,"word": " "},{"categoryId": 41,"word": " "}]}
With lansa i have used the HTTPService :
* Open service
Use Builtin(JSMX_OPEN) To_Get(£JSMXSTS £JSMXMSG £JSMXHDLE1)
* Load service
£JSMXCMD := 'SERVICE_LOAD SERVICE(HTTPService) SERViCE_CONTENT(*JSON)'
£JSMXCMD += ' TRACE(*YES) TRACE_NAME(APPEL_GED_REST)'
Use Builtin(JSMX_COMMAND) With_Args(£JSMXHDLE1 £JSMXCMD) To_Get(£JSMXSTS £JSMXMSG)
* Build POST Values
£W_NAME := 'clearCriterionList'
£W_VALUE := "false"
Add_Entry To_List(£LIST)
* Call the service£LIST
£JSMXCMD := 'SEND HANDLER(OutboundNameValue) HOST(' + £pHOSTname + ') URI(' + £pURIpath + ') METHOD(PATCH) SERVICE_LIST(W_NAME,W_VALUE) USER(webservice) PASSWORD(DOCUBASE) CONTENT(*JSON)'
Use Builtin(JSMX_COMMAND) With_Args(£JSMXHDLE1 £JSMXCMD) To_Get(£JSMXSTS £JSMXMSG £LIST)
i need help
i need to consume an REST API from EDM environnement. i have make the request on SOAP-ui and it works well, the document name was changed, but i do not have success with LI :
Command : ERROR "Erreur de réception de la réponse HTTP"
{"message":"[HttpMessageNotReadableException] Could not read JSON document: Unrecognized token 'clearCriterionList': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (PushbackInputStream); line: 1, column: 20]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'clearCriterionList': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (PushbackInputStream); line: 1, column: 20]"}
On SOAP-UI I used this URL :
http://servrged1/serviceweb/rest/api/us ... main/<parm 1>/base/<parm 2/document/<parm 3>/tag?clearCriterionList=false
"parm 1" is an identifiant of domains to work
"parm 2" is an identifiant of database to access
"parm 3" is the document id
I need also tha have in the body
{"criterionList": [{"categoryId": 38,"word": "ANNULE"},{"categoryId": 39,"word": " "},{"categoryId": 40,"word": " "},{"categoryId": 41,"word": " "}]}
With lansa i have used the HTTPService :
* Open service
Use Builtin(JSMX_OPEN) To_Get(£JSMXSTS £JSMXMSG £JSMXHDLE1)
* Load service
£JSMXCMD := 'SERVICE_LOAD SERVICE(HTTPService) SERViCE_CONTENT(*JSON)'
£JSMXCMD += ' TRACE(*YES) TRACE_NAME(APPEL_GED_REST)'
Use Builtin(JSMX_COMMAND) With_Args(£JSMXHDLE1 £JSMXCMD) To_Get(£JSMXSTS £JSMXMSG)
* Build POST Values
£W_NAME := 'clearCriterionList'
£W_VALUE := "false"
Add_Entry To_List(£LIST)
* Call the service£LIST
£JSMXCMD := 'SEND HANDLER(OutboundNameValue) HOST(' + £pHOSTname + ') URI(' + £pURIpath + ') METHOD(PATCH) SERVICE_LIST(W_NAME,W_VALUE) USER(webservice) PASSWORD(DOCUBASE) CONTENT(*JSON)'
Use Builtin(JSMX_COMMAND) With_Args(£JSMXHDLE1 £JSMXCMD) To_Get(£JSMXSTS £JSMXMSG £LIST)
i need help