Forum Discussion
OneNote create page with multipart/form-data - The multi-part payload was malformed.
- Mar 28, 2023
After working with Microsoft to resolve, it turns out that the Power Automate UI has a tendency to strip out \r aka CR (Carriage Return) aka %0D characters whereas the OneNote API is very picky and requires CRLF end of line characters, so we need to sub LF back in. And the replacement should be in the HTTP action body or there is a good chance they get striped out again and it fails.
If variables(strBody) is your payload;
Content-Length == length(replace(variables('strBody'),uriComponentToString('%A'),uriComponentToString('%0D%A')))
Body == replace(variables('strBody'),uriComponentToString('%0A'),uriComponentToString('%0D%0A'))
After working with Microsoft to resolve, it turns out that the Power Automate UI has a tendency to strip out \r aka CR (Carriage Return) aka %0D characters whereas the OneNote API is very picky and requires CRLF end of line characters, so we need to sub LF back in. And the replacement should be in the HTTP action body or there is a good chance they get striped out again and it fails.
If variables(strBody) is your payload;
Content-Length == length(replace(variables('strBody'),uriComponentToString('%A'),uriComponentToString('%0D%A')))
Body == replace(variables('strBody'),uriComponentToString('%0A'),uriComponentToString('%0D%0A'))
Thanks so much for sharing your findings. This would have taken me forever to figure out.