1. Ed Van Haren
  2. PowerBuilder
  3. Monday, 12 March 2018 21:35 PM UTC

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);
}

 

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 13 March 2018 07:25 AM UTC
  2. PowerBuilder
  3. # 1
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.