Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post doesn't work as expected #33

Closed
DomasB opened this issue Jan 27, 2020 · 2 comments
Closed

Post doesn't work as expected #33

DomasB opened this issue Jan 27, 2020 · 2 comments

Comments

@DomasB
Copy link

DomasB commented Jan 27, 2020

Hi,
In my test I am doing this:

newUser := &models.User{
		Name: "New user",
		Email: "new@test.com",
	}
res := as.HTML("/users").Post(newUser)

The code seems to be identical as in the example.
However, I get an error: invalid character 'C' looking for beginning of value

When I log c.Request().Body in my action I get
CreatedAt=&Email=new%40test.com&ID=00000000-0000-0000-0000-000000000000&Name=New+user&UpdatedAt=
I understand that is where 'C' in the error comes from.

However, if I test my endpoint from Postman in the live app, c.Request().Body logs

{
	"name": "New User",
	"email": "test@test.lt"
}

It seams like Post method sends my model's data as parameters instead of json body.
How could this be fixed?

Thank you for your help!

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant