Basically I need to post data to a Thread, the API is from Mirakl. For example... send message to the Operator, or the Client. JSON form. Normally I only need to send the message, but if anyone could explain how I send files, would appreciate too.
cURL request example
Code: Select all
curl --location --request POST 'https://host.com/api/inbox/threads/{THREAD_ID}/message' \
-H "Authorization: {API_KEY}" \
-H "Content-Type: multipart/form-data" \
--form 'message_input={
"body": "Message body",
"to": [
{
"type": "OPERATOR"
}
]
};type=application/json' \
--form 'files=@/path/to/file.pdf'
Code: Select all
ReplyToThread(){
message_input={"body": "Message body","to": [{"type": "OPERATOR"}]}
obj := Jxon_Load(message_input)
URL := "https://" SetMiraklUrl() "/api/inbox/threads/" this.GetID() "/message"
CreateFormData(postData, hdr_ContentType, obj)
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HttpObj.Open("POST", URL, true)
HttpObj.SetRequestHeader("Content-Type", hdr_ContentType)
HttpObj.SetRequestHeader("Authorization", SetMiraklKey())
HttpObj.Send(postData)
HttpObj.WaitForResponse()
Result := HttpObj.ResponseText
Status := HttpObj.Status
If (Status = 201)
MsgBox, Message Sent
If (Status != 201)
msgbox % "status: " status "`n`nresult: " result
}
Do I need to send the message_input, with Json_Load ?