Issue
I am trying put comment to GitHub PR using curl command but as my comment has multiple lines, it is failing to do so and throwing error:
"message": "Problems parsing JSON",
Here is how i'm trying it: I have comment content available on fileA.
var1=`cat fileA`
curl -u $user:$token -X POST -H 'Accept: application/vnd.github+json' -d '{\"body\":\"$var1\"}' $URL
Tried with and without -H option but it doesn't really make any change.
Sample FileA:
PR Changes looks okay.
Changes can be merged to main branch.
Approved.
Any help would be appreciated.
Solution
Have got an answer:
By updating file content. Need to replace \n(newline) in file with
and then post it to GitHub Comment.
FileA(before):
PR Changes looks okay.
Changes can be merged to main branch.
Approved.
FileA(after):
PR Changes looks okay.<br>Changes can be merged to main branch.<br>Approved.
If you still face parsing issue try replacing "(double quotes) with '(single quotes)' - i faced this issue also.
Answered By - uni Answer Checked By - Cary Denson (WPSolving Admin)