-
|
Hi, I'm trying to send a POST request with some data to an MLflow model endpoint and get back the response (I'm following the MLflow docs: Deploy MLflow Model as a Local Inference Server). The problem is, I don't know how to properly configure a POST request in ThingsBoard Gateway's Request connector. The docs only show examples for GET requests, like this one in request.json: {
"url": "getdata",
"httpMethod": "GET",
"httpHeaders": {
"ACCEPT": "application/json"
},
"content": {
"name": "morpheus",
"job": "leader"
}
}If I try with {
"url": "invocations",
"httpMethod": "POST",
"httpHeaders": {
"ACCEPT": "application/json"
},
"contents": {
"inputs": [
[
-0.955945000492777,
-0.34598177569938643,
-0.4635959746460942,
0.4814814737734622
]
]
}INFO: 10.88.0.2:60154 - "POST /invocations HTTP/1.1" 500 Internal Server ErrorI looked at the code and found a reference to a data parameter, but I can't confirm if it works. Because when I change {
"url": "invocations",
"httpMethod": "POST",
"httpHeaders": {
"ACCEPT": "application/json"
},
"data": {
"inputs": [
[
-0.955945000492777,
-0.34598177569938643,
-0.4635959746460942,
0.4814814737734622
]
]
}INFO: 10.88.0.2:39104 - "POST /invocations HTTP/1.1" 415 Unsupported Media TypeHas anyone successfully configured a POST request with JSON payload using the Request connector? Any example, config or tips on how to set the payload properly would be super helpful. The docs is a bit vague about that: Request Connector Configuration Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @trya2l, Here is an example of RPC configuration for POST request: {
"deviceNameFilter": ".*",
"methodFilter": "post_test",
"requestUrlExpression": "/",
"responseTimeout": 1,
"httpMethod": "POST",
"requestValueExpression": "${params}",
"responseValueExpression": "${message}",
"timeout": 0.5,
"tries": 3,
"httpHeaders": {
"Content-Type": "application/json"
}
},Data from params from request will be send as body to the server, Server respond to the request with the following body: {
"message": "Hello World"
}Probably in your case, you just need change ACCEPT to Content-Type in httpHeaders. |
Beta Was this translation helpful? Give feedback.

Hi @trya2l,
Here is an example of RPC configuration for POST request:
{ "deviceNameFilter": ".*", "methodFilter": "post_test", "requestUrlExpression": "/", "responseTimeout": 1, "httpMethod": "POST", "requestValueExpression": "${params}", "responseValueExpression": "${message}", "timeout": 0.5, "tries": 3, "httpHeaders": { "Content-Type": "application/json" } },Data from params from request will be send as body to the server,
messagefield from response will be parsed and returned as a result.Server respond to the request with the following body:
{ "message": "Hello World" }Request sending:
Probably in…