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

Error when creating book using swagger & curl #8

Open
4 tasks done
ganjarsetia opened this issue Jul 8, 2022 · 3 comments
Open
4 tasks done

Error when creating book using swagger & curl #8

ganjarsetia opened this issue Jul 8, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ganjarsetia
Copy link

ganjarsetia commented Jul 8, 2022

Required check list:

  • I'm gonna mark the checkboxes like this.
  • I didn't find in the repository's issues section similar bug.
  • I understand, this is Open Source and not-for-profit product.
  • This is not about third-party project, framework, package or technology.

My environment:

  • OS (uname -a): Linux 89327648a97a 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 Linux (inside docker)
  • Golang (go version): go version go1.18.3 linux/amd64

Describe the bug:

I followed your article & successfully run it. But when I tried to test the create book API, it fail. I tried using Swagger, it still the same. Do you have any sample JSON for create book ?

Steps to reproduce the behavior:

  1. Run the app like shown in readme & run the migration. Make sure no records in DB.
  2. Generate token & copy the token using swagger or curl -X 'GET' 'http://127.0.0.1:5000/api/v1/token/new' -H 'accept: application/json'
  3. Put the token at swagger. By click "Authorize" button on top right. Fill with Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTczMDIzNzF9.0VJubL5Z_49W2-9BHvqQaFn2pN1TxkysFIvzb5SpUow
    image
  4. Try Swagger POST /v1/book by clicking Try It Out & fill Title, Author, etc. image
  5. Click Execute
  6. See error image

I tried to change the JSON, it still error, you can try this curl

curl -X 'POST' \
  'http://127.0.0.1:5000/api/v1/book' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTcyOTc2NzN9.fCjWNsiCVoUecjY1fhKNB_zHrZWS3SQohTeese5HdqM' \
  -H 'Content-Type: application/json' \
  -d '{
  "author": "Michael Crichton",
  "book_attrs": {
    "description": "A cautionary tale about genetic engineering",
    "picture": "https://upload.wikimedia.org/wikipedia/en/3/33/Jurassicpark.jpg",
    "rating": 8
  },
  "title": "Jurassic Park"
}

And it show error
{"error":true,"msg":{"ID":"Key: 'Book.ID' Error:Field validation for 'ID' failed on the 'uuid' tag","UserID":"Key: 'Book.UserID' Error:Field validation for 'UserID' failed on the 'uuid' tag"}}

Expected behavior:

Successfully create book

Screenshots:

image

@ganjarsetia ganjarsetia added the bug Something isn't working label Jul 8, 2022
@welcome
Copy link

welcome bot commented Jul 8, 2022

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template!

@stale
Copy link

stale bot commented Jun 1, 2023

👋 Hello. Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 1, 2023
@ganjarsetia
Copy link
Author

wave Hello. Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

Yes. The problem already told in first thread. I dont know how to solve it

@stale stale bot removed the wontfix This will not be worked on label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants