#5284 Can't comment on issue using API - 400 Bad Request
Closed: Invalid by zlopez. Opened by zlopez.

Here is the quick reproducer for this issue I tried to use on staging:

curl -X POST -H "Authorization: token <token with issue comment permission>" -H "Content-Type: application/json" -d "{'comment': 'comment'}" https://stg.pagure.io/api/0/releng/fedora-scm-requests/issue/260/comment

It always returns 400 Bad Request.

I tried to dig more in the code and found out that the CommentForm comment field is validated as wtforms.FileField, which doesn't get validated if you follow the comment as string. I could create a fix for this, but I'm not sure if this isn't intentional.


This should be covered in the tests suite. Are we doing anything special in
there?

The comment button works without issue, I will look at the API more closely today.

Ok, found out that the json in curl is really sensitive on the kind of quotes you use:
When I tried:

curl -X POST -H "Authorization: token <token with issue comment permission>" -H "Content-Type: application/json" -d '{"comment": "comment"}' https://stg.pagure.io/api/0/releng/fedora-scm-requests/issue/260/comment

the request worked.

So the bad was on my side :-/ Closing the issue.

Metadata Update from @zlopez:
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

Metadata