ravendb / samples-yabt

"Yet Another Bug Tracker" solution sample for RavenDB and .NET with Angular UI
https://yabt.ravendb.net
MIT License
109 stars 22 forks source link

[HelpNeeded] Request body for creating new bug with custom fields #55

Closed chesthar closed 2 years ago

chesthar commented 2 years ago

Hi,

I need the request body for creating a new bug with a custom field of type text. I've played a little bit with the API and couldn't figure out the proper JSON body that I need to pass in order to use the custom field of type text when creating a new bug. An example of such bug with a custom field already present in the live system is https://yabt.ravendb.net/backlog-items/13934-A. It had a custom field "Original URL" and I've added another custom field(from the dropdown on the FE) to it of the type "Test text".

using local setup of Yabt latest master : dbb166786e5a4f1aab9626d6b7501d0252d6db6e

Note: I've noticed that new bugs that I'm creating from the swagger in my local instance of Yabt can't be shown on the frontend: curl -X 'POST' \ 'http://localhost:5000/api/BacklogItems/bug' \ -H 'accept: text/plain' \ -H 'X-API-Key: 4D84AE02-C989-4DC5-9518-8D0CB2FB5F61' \ -H 'Content-Type: application/json' \ -d '{ "title": "My Bug Title", "state": "new", "severity": "critical", "priority": "p1", "stepsToReproduce": "my steps to reproduce", "acceptanceCriteria": "my acceptance criteria" }'

outputs: { "type": "bug", "id": "32652-A", "name": "My Bug Title" }

when query the frontend(http://localhost:4200/backlog-items/32652-A) I get the following error: "Failed to fetch

Not Found"

the bug item is retrieved without a problem from http://localhost:5000/api/BacklogItems/32652-A. Any clue what I'm doing wrong?

AKlaus commented 2 years ago

Most likely, you're using different API keys between Swagger UI and the Angular UI. Since v2.0 (see What's new), YABT has become multi-tenanted and if the current user belongs to one tenant and requests an item from another, the system returns 404 Not Found.

You can use releases before v2.0 if multi-tenancy causes unnecessary complexity. Or pay attention to the API keys

chesthar commented 2 years ago

Thanks a lot. You instantly nailed the root cause of my problem. I was using the first API key in swagger which is for tenant 1-A while the FE is using tenant 2-A. Switching the API keys solved the problem and at last, I was able to see how to construct the request for a new bug with custom fields

curl -X 'POST' \
  'http://localhost:5000/api/BacklogItems/bug' \
  -H 'accept: text/plain' \
  -H 'X-API-Key: 4C81D6EC-AA5A-4799-8538-84E31CF5493B' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "New Bug With Custom Fields",
  "state": "new",
  "severity": "critical",
  "priority": "p1",
  "stepsToReproduce": "my steps to reproduce",
  "acceptanceCriteria": "my A/C",
  "changedCustomFields": [
    {
      "customFieldId": "328-A",
      "value": "http://newbugWithCustomFields.com",
      "actionType": "add"
    }
  ]
}'