Yet another sendHttpPostRequest help thread trying to get Compreface face recognition working

Hi all, put all my hair off today trying to get face recognition service working. What i need is to send an http post request in a form like:

curl -X POST "http://localhost:8001/api/v1/recognition/recognize?face_plugins=landmarks, gender, age" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: fe899886-9d0f-4fd0-860a-406c5b1623de" \
-F "file=@/openhab/video/domofon/ipcamera.jpg"

What i’ve got so far:

executeCommandLine(Duration.ofSeconds(1), "bash","curl -L 'http://localhost:8080/ipcamera/Kalitka/ipcamera.jpg' -o /openhab/video/domofon/ipcamera.jpg")
val String comprefaceEndpoint = "http://localhost:8001/api/v1/recognition/recognize?limit=2&det_prob_threshold=0.9"
val String comprefaceContentType = "multipart/form-data"
val comprefaceApiKey = newHashMap("x-api-key" -> "fe899886-9d0f-4fd0-860a-406c5b1623de")
var String comprefaceJpeg = "-F file=@/openhab/video/domofon/ipcamera.jpg"
var String faceRecognitionRawResult = sendHttpPostRequest(comprefaceEndpoint,comprefaceContentType,comprefaceJpeg,comprefaceApiKey,10000).toString
logWarn("face", faceRecognitionRawResult.toString)
  FaceRecognitionTrigger.sendCommand(OFF)

I receive something like:

{
  "message" : "Something went wrong, please try again",
  "code" : 0
}

So obviously something gone wrong here. And a can’t find out, what.

Oh, and curl --location -g --request POST 'http://localhost:8001/api/v1/recognition/recognize?limit=2&det_prob_threshold=0.9' --header 'Content-Type: multipart/form-data' --header 'x-api-key: fe899886-9d0f-4fd0-860a-406c5b1623de' --form 'file=@/openhab/video/domofon/ipcamera.jpg' -o '/openhab/video/domofon/face.txt'
does work from console, while exactly the same line doesn’t work from rule
executeCommandLine(Duration.ofSeconds(3), "bash","curl --location -g --request POST 'http://localhost:8001/api/v1/recognition/recognize?limit=2&det_prob_threshold=0.9' --header 'Content-Type: multipart/form-data' --header 'x-api-key: fe899886-9d0f-4fd0-860a-406c5b1623de' --form 'file=@/openhab/video/domofon/ipcamera.jpg' -o '/openhab/video/domofon/face.txt'")

You need to separate every argument by using commas.

I’ve tried to, but got no luck. Just got away from Openhab exec in this case and used Asterisk to do the job:

[test]
;;;;;;;;;;;;;;;;;;
;DoorButton2
;;;;;;;;;;;;;;;;;;
exten => 9902,1,Ringing()
exten => 9902,2,TrySystem(curl -L 'http://localhost:8080/ipcamera/Kalitka/ipcamera.jpg' -o /export/Data/domofon/ipcamera.jpg)
exten => 9902,3,TrySystem(curl --location -g --request POST 'http://localhost:8001/api/v1/recognition/recognize?limit=2&det_prob_threshold=0.9' --header 'Content-Type: multipart/form-data' --header 'x-api-key: fe899886-9d0f-4fd0-860a-406c5b1623de' --form 'file=@/export/Data/domofon/ipcamera.jpg' -o '/export/Data/domofon/face.txt')
exten => 9902,4,TrySystem(curl -X POST 'http://192.168.2.9:8080/rest/items/FaceRecognitionResult' -H 'accept: */*' -H 'Content-Type: text/plain' -F 'state=</export/Data/domofon/face.txt' 'http://localhost:8080/rest/items/FaceRecognitionResult')
exten => 9902,5,TrySystem(rm -f /export/Data/domofon/ipcamera.jpg /export/Data/domofon/face.txt)
exten => 9902,n,Hangup()

That’s a solution in my case, cause I only want to recognize faces when doorphone secondary button is pressed, but for others, who will try to recognize faces when their ip cameras will trigger motion alarm of human presence alarm, that won’t work, so Openhab-based solution is still wanted.