DEV Community

Discussion on: API With GO Buffalo in 2021: from zero to deploy

Collapse
 
robinhuiser profile image
Robin Huiser

I tried to add an entry - but all seem to fail:

$ curl 'http://localhost:3000/todo/add?item=apple'    
Enter fullscreen mode Exit fullscreen mode

... this results into:

{"Severity":"ERROR","Code":"22P02","Message":"invalid input syntax for type integer: \"fe587612-c134-40b8-954b-b199bf51a87e\"","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"numutils.c","Line":323,"Routine":"pg_strtoint32"}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
alexmercedcoder profile image
Alex Merced

try converting the param to a string in the function strconv.atoi. I'll double check why it was working for me in a bit.

Collapse
 
alexmercedcoder profile image
Alex Merced

The reason it works for me is cause I send the body via JSON so it's an integer, but if you send it via URL query it will be a string