Error while posting expense: Category can't be blank

Hi there,

I’m having trouble creating an expense via API. Getting an error when
running this httpie request:

http POST "" "Authorization:
Bearer $access_token" user=""
 dated_on="2019-01-24" description="Test" gross_value="10.00"

HTTP/1.1 422 Unprocessable Entity
“errors”: [
“message”: “category can’t be blank”

I’ve also tried as specified by the documentation to send a root
object expense, but whe I do that I get a different error:

http --form POST ""
"Authorization: Bearer $access_token"
{"expense":    {"user":"","category":"",gross_value="10.00","dated_on":"2019-01-24","description":"Test"}}

HTTP/1.1 400 Bad Request
“errors”: {
“error”: {
“message”: “Expense or expenses data required”

Any help would be appreciated!

Your data structure looks correct; it works for me with curl:

curl \
  -H "Authorization: Bearer $token" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -X POST \
  -d '{"expense":{"user":"', "category":"", "description":"test", "gross_value":"12.34", "dated_on":"2019-01-30"}}'

So I think you need to read the docs for httpie a bit more :wink:


I think the Accept and Content-type could be the parameters I need! I’m gonna try soon. Thank you!