Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. #24

Open
ikramulmustafa opened this issue May 22, 2019 · 7 comments

Comments

@ikramulmustafa
Copy link

ikramulmustafa commented May 22, 2019

curl -X GET "http://127.0.0.1:8000/api/v1/store/getStoreByCat" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "category_id=481&language_id=3"

Everything is running in Postman with same Methods and i dont know where is the problem can any one help me with this

/**

  • @swg\GET (path="/store/getStoreByCat",

  • tags={"Get Store By Category"},
    
  • @SWG\Parameter(
    
  •     name="category_id",
    
  •     in="formData",
    
  •     type="string",
    
  •     description="ID recieved to Show Sellers base on Category ID",
    
  •     required=true,
    
  • ),
    
  •   @SWG\Parameter(
    
  •     name="language_id",
    
  •     in="formData",
    
  •     type="string",
    
  •     description="ID recieved to Show Sellers base on language",
    
  •  ),
    
  • summary="Show Sellers base on Categories",
    
  • @SWG\Response(
    
  •     response = 200,
    
  •     description = "ID recieved to Show Sellers base on Category ID where 'seller_id' in categories is 1.",
    
  •     examples={
    
  • "application/json": {
    
  • "data":{
    
  •       "category_id": 481,
    
  •       "category_name": "Computer",
    
  •       "description": "GOOD ",
    
  •       "id": 19,
    
  •       "image": "Aswaq_Wadi/aswaq-wadi-logo.jpg",
    
  •       "banner": "Aswaq_Wadi/Aswaq-wadi.jpg",
    
  •       "minimum_order": 99,
    
  •       "delivery_charges": 15,
    
  •       "latitude": 25,
    
  •       "longitude": 47,
    
  •      "rating": "0",
    
  •       "name": "Aswaq Wadi",
    
  •      "delivery": "Next Delivery  Today 09:00 am - 11:00 am"
    
  •      },"statusCode":true
    
  • }
    
  • }

  • ), @SWG\Response(
    
  •     response = 422,
    
  •     description = "No Seller Categories against this category ID.",
    
  •     examples={
    
  • "application/json": {
    
  • "error":{
    
  • {
    
  •   "field"="category_id",
    
  •   "message"="missing ID"
    
  • },
    
  • {
    
  •   "field"="language_id",
    
  •   "message"="missing ID"
    
  • }
    
  • },"statusCode":false
    
  • }

  • }
    
  • ),
    
  • )
    */

@fgreinus
Copy link
Member

Using the -d option will set the POST-Data. So you will have a body included in the request. Just append the GET parameters to the URL like this:

curl -X GET "http://127.0.0.1:8000/api/v1/store/getStoreByCat?category_id=481&language_id=3" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded"

@ikramulmustafa
Copy link
Author

WHERE should i add this?

@ikramulmustafa
Copy link
Author

/**

  • @swg\Swagger(

  • host="127.0.0.1:8000",
    
  • basePath="/api/v1",
    
  • produces={"application/json"},
    
  • consumes={"application/x-www-form-urlencoded"},
    
  • @SWG\Info(version="1.0", title="Qareeb API v1"),
    
  • )
    */
    i have inculded this in other main controller

@fgreinus
Copy link
Member

Is it working in Postman or is it working in SwaggerUI?

@fgreinus fgreinus reopened this May 22, 2019
@ikramulmustafa
Copy link
Author

Yes its working in postman

@ikramulmustafa
Copy link
Author

the api's in which i donnot have to pass parameters are geetting data in swagger but like this one i shared in which i have to pass parameter it give me this error

@ikramulmustafa
Copy link
Author

and same path and with method every api is working in postman

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

No branches or pull requests

2 participants