How to add accessToken in Guzzle service description?

PHP 7.3.24
Symfony 4

I want to pass some static value as token in my request, I am referring this documentation, but not able to get how I can set header.

my service description json looks like

{
  "name": "MyAPI",
  "description": "My API",
  "operations": {
    "getMyData": {
      "httpMethod": "POST",
      "uri": "get/mydata/{?user_id}",
      "summary": "get my data",
      "responseModel": "getMyData",
      "parameters": {
        "Content-Type": {
          "location": "header",
          "type": "string",
          "default": "application/json"
        },
        "token": {
          "location": "header",
          "type": "string",
          "default": "SOME_CONSTANT"
        },
        "code": {
          "location": "header",
          "type": "string",
          "default": "SOME_CONSTANT"
        },
        "command.name": {
          "location": "header",
          "type": "string",
          "default": "getMyData"
        }
      }
    }
  }
}

The result is bad request.

Source: Symfony4 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *