The original CURL I'm trying to submit is like this
Code: Select all
curl --location --request POST 'https://XXX.com/api/v2/photos/' \
--header 'Authorization: Bearer YYY' \
--form 'visit_id="custom_visit_141020214319311"' \
--form 'photo_id="14102021190755-1999"' \
--form 'photo_data=@"/C:/Users/alex_/Downloads/2021-10-07-07-18-44-5424-o.jpg"' \
--form 'scene_id="6168005a6a929-9084"'
Code: Select all
on mouseUp
put "YYY" into myToken
-- build the header(s)
put empty into tHeader
put "Authorization:Bearer " & myToken into tHeader
set the httpHeaders to tHeader
-- load the image data
put "/Users/simonschvartzman/Downloads/Pic1.jpg" into theFilePath
put URL ("binfile:" & theFilePath) into theBinaryData
-- build the body
put quote & "visit_id" & quote & ":" & quote & "custom_visit_141020214319311-1" & quote & "," & CR into tMsg
put quote & "photo_id" & quote & ":" & quote & "14102021190755-1999-1" & quote & "," & CR after tMsg
put quote & "photo_data" & quote & ":" & quote & "@/Users/simonschvartzman/Downloads/Pic1.jpg" & quote & "," & CR after tMsg
put quote & "scene_id" & quote & ":" & quote & "6168005a6a929-9084-1" & quote after tMsg
put tMsg into tArgList
put "{" & tMsg & "}" into tArgList
-- set the URL for the photo method
put "https://XXX.com/api/v2/photos/" into tURL --the url
-- fire the request
post tArgList to url tURL
-- get the result
put it into tResponse
put tResponse
end mouseUp
I know photo_data is not properly set but for now I don't care since first I have to get rid of the other two errors{"type":"error","message":"3 validation errors for Request\nbody -> photo_id\n field required (type=value_error.missing)\nbody -> visit_id\n field required (type=value_error.missing)\nbody -> photo_data\n field required (type=value_error.missing)","status":422}
ps: since my end goal is to deploy in mobile using libURLFormData doesn't apply...
Anyone willing/able to help? Many thanks