Mar 20 2023 08:07 PM
Good day,
I am trying to create a OneNote page using the Graph OneNote endpoint below, but can't seem to get the multipart right and keep on getting an error that "The multi-part payload was malformed."
https://graph.microsoft.com/v1.0/groups/{id}/onenote/sections
Any ideas what could be wrong with the below?
Mar 27 2023 06:05 PM
SolutionAfter 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'))
Jan 03 2024 07:38 AM
Thanks so much for sharing your findings. This would have taken me forever to figure out.
Mar 27 2023 06:05 PM
SolutionAfter 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'))