I'm using HTTPAPI to post to a rest service that requires one element to be base64 encoded and I'm running into a tranlation problem.
My json needs to be
{
"file":"base64encodedfilecontents",
"replace":"true",
"domain":"Default"
}
in my rpg program I'm reading a text file into a string then encode it using the base64_encode function. Then I put it together as shown above and post it with http_url_post. I get a 400 response - Unable to parse xml file: Content is not allowed in prolog.
how can I properly encode my request?
Rest Service Post Json containing Base64 encoded data
-
- Posts: 2
- Joined: Wed Apr 19, 2023 7:04 pm
Re: Rest Service Post Json containing Base64 encoded data
Have you told HTTPAPI to use the correct CCSID for the network? e.g.
If that is not the issue we'll need to see more of your code.
Code: Select all
http_setOption ( 'network-ccsid' : '1208' );
-
- Posts: 2
- Joined: Wed Apr 19, 2023 7:04 pm
Re: Rest Service Post Json containing Base64 encoded data
I figured it out. I opened the file with the O_Textdata flag so I encoded the ebcdic data. I removed it and it's fine now.
Re: Rest Service Post Json containing Base64 encoded data
Yup - that would have screwed it up even better!
Glad you sorted it out.
Glad you sorted it out.