Using PB2017R2 and multipartform


I have C# code below that I want to translate to PowerBuilder 2017R2. This code is passing some JSON and a PDF to a REST API call. Not sure how to translate this to PowerBuilder R2. Basically need to know how to translate the multipartForm. Any help would be greatly appreciated.

var uri = $"http://xxx/Correspondence/Upload";
HttpResponseMessage response;

using (var client = new HttpClient())
 var multipartForm = new MultipartFormDataContent();

 string jsonObject = '{"Access":"A", "Archive":"N","Product":"CLAIM"}'

 var content = new StringContent(jsonObject, Encoding.UTF8, "application/json");
 content.Headers.Add("Content-Disposition", "form-data; name=\"docKey\"");
 multipartForm.Add(content, "docKey");

 var filePath = Path.Combine(@"C:\Dev\wcb.CAS.Mstr\wcb.CAS.UnitTests\TestData", "Test.pdf");
 var pdf = File.ReadAllBytes(filePath);
 var file = new ByteArrayContent(pdf);
 file.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
 file.Headers.Add("Content-Disposition", "form-data;name=\"docFile\";filename=\"Test\"");
 multipartForm.Add(file, "docFile");

 response = client.Post(uri, multipartForm);


Question Tags: