Hi Renee, I am trying to make a token request to azure using that works in Postman, but cannot make it from PB.
I tried using loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.6.0") and HttpClient with the same result
The content from postman is:
I tried filling the variable like this:
s_BOUNDARY = "$$$Boundary$$$"
body="grant_type:~"client_credentials~""+char(10)+&
"client_id:~"xxxxxxxxxxxxxxxxx~""+char(10)+&
"client_secret:~"xxxxxxxxxxxxxxxxxxxxx""+char(10)+&
"scope:~"https://apiedwh.azurewebsites.net/.default~""
lblob_data = blob ("--" + ls_BOUNDARY + "~r~n" + &
"~r~n~r~n" + body + "~r~n", EncodingUTF8!)
lblob_data = lblob_data + blob ("--" + ls_BOUNDARY + "~r~n" , EncodingUTF8!)
lnv_HttpClient.SetRequestHeader("Content-Type", "multipart/form-data; boundary=--" + ls_BOUNDARY)
integer li_rc
li_rc = lnv_HttpClient.SendRequest("POST", requestendpoint,lblob_data)
The result is 400, does not recognize the parameters in the multiform part
Can you give a hint on what to look for.
Best Regards
Alfredo
With your example above I was able to put it together and get it working. Knowing that it it was just a blob of other blobs did the trick. An example using HTTPClient is below.
// Read the file into a blob
ll_FileNum = FileOpen('TEST.PDF', StreamMode!)
FileReadEx(ll_FileNum, blb_file)
FileClose(ll_FileNum)
ls_FileName = 'TEST.PDF'
ls_MimeType = 'application/pdf'
// Create a boundary marker for the multipart blob
ls_BOUNDARY = "$$$Boundary$$$"
// Create component blobs
blb_boundary = blob('~r~n--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_terminus = blob('~r~n--' + ls_Boundary + '--~r~n', EncodingUTF8!)
blb_filename = blob('Content-Disposition: form-data; name="File-Name"' + '~r~n~r~n' + ls_FileName, EncodingUTF8!)
blb_mimetype = blob('Content-Disposition: form-data; name="Mime-Type"' + '~r~n~r~n' + ls_MimeType, EncodingUTF8!)
blb_file = blob( 'Content-Disposition: form-data; name="File"; filename="' + ls_FileName + '"' + '~r~n' + &
"Content-Type: " + ls_MimeType + "~r~n~r~n", EncodingUTF8!) + &
blb_file
// Concatenate blobs into a single multipart blob
blb_multipart = blb_boundary + &
blb_filename + &
blb_boundary + &
blb_mimetype + &
blb_boundary + &
blb_file + &
blb_terminus
// HTTPClient
inv_httpClient.clearrequestheaders()
inv_httpClient.setrequestheader('Access-Token', sle_access_token.text)
inv_httpClient.SetRequestHeader("Content-Type", "multipart/form-data; boundary=" + ls_BOUNDARY)
inv_httpClient.SendRequest('POST', ls_url, blb_multipart)
inv_httpClient.GetResponseBody(ls_json)