Skip to content

Creating response json block based on the API result  #768

Description

@bharatid

How to create response json block based on the API result which is in json format. Tried many ways from the doc I have seen, still get failure.
My tavern test:

# ===================================================================
# New Business Partner (BP) and full-setup, similar to full-setup.rtt
# ===================================================================
# Testing deployment, 220221, 10:47
includes:
  - !include config/common.yaml

test_name: Tavern POC, SAS-2279, New Business Partner/Customer, full setup, and NSQ

# Additional keys in JSON and headers OK
strict:
 - headers:off
 - json:off
 #- response:off    Does not work

marks:
  # For Shipwire Api calls, hostname on which the test is run is needed
  - usefixtures:
      - get_randomstr_len1
      - get_randomstr_len10
      - get_host_name

# Create SAP customer using endpoint which uses Recurring Billing APIs
stages:

  # SignIn
  - name: Signon Using the Newly Created Business Partner/Customer using SW API
    request:
      url: http://merchant.developer.corp.shipwire.com/data/auth
      method: GET
      json:
        user: aee99fbea4d14b619fe5929ae118595f+fakedev_shipwire_net+fakedev@shipwire.net
        pass: Ingram?123
      headers:
        Content-Type: application/json
    response:
      status_code: [200]
      json:
        code: !anystr
        message: !anydict
        url: !anystr
        result: !anydict    
        state: !anylist
      #headers:
      #cookies:
      #  - PHPSESSID
      #  set_cookie: 
      #    PHPSESSID: !anystr
      #  content-type: application/json
      #- __swCustomerPreferences

The response, got 200:

status code [400]
{
  "code": "VALIDATION",
  "message": {
    "*": [
      "Incomplete data provided. Missing properties \"code\"."
    ]
  },
  "url": "/data/auth",
  "result": {
    "meta": [],
    "data": {
      "trace": [
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/JsonResponseDataParser/InternalApiJsonResponseDataParser.php",
          "line": 50,
          "function": "getExceptionForErrorType",
          "class": "Shipwire\\ApiClient\\GenericApiErrorHandler",
          "type": "::"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/GenericApiErrorHandler.php",
          "line": 140,
          "function": "getError",
          "class": "Shipwire\\ApiClient\\JsonResponseDataParser\\InternalApiJsonResponseDataParser",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/GenericApiErrorHandler.php",
          "line": 98,
          "function": "_handleAll",
          "class": "Shipwire\\ApiClient\\GenericApiErrorHandler",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/GenericGateway.php",
          "line": 445,
          "function": "process",
          "class": "Shipwire\\ApiClient\\GenericApiErrorHandler",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/GenericGateway.php",
          "line": 578,
          "function": "setResponse",
          "class": "Shipwire\\ApiClient\\GenericGateway",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/GenericGateway.php",
          "line": 389,
          "function": "getProcessedResponse",
          "class": "Shipwire\\ApiClient\\GenericGateway",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/module/Main/src/Main/Library/Auth/Auth.php",
          "line": 28,
          "function": "fetch",
          "class": "Shipwire\\ApiClient\\GenericGateway",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/module/Main/src/Main/Controller/AuthController.php",
          "line": 47,
          "function": "verify",
          "class": "Main\\Library\\Auth\\Auth",
          "type": "::"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/shipwire/internal-shipwire-api-client/src/Shipwire/ApiClient/AbstractController.php",
          "line": 282,
          "function": "getList",
          "class": "Main\\Controller\\AuthController",
          "type": "->"
        },
        {
          "function": "onDispatch",
          "class": "Shipwire\\ApiClient\\AbstractController",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php",
          "line": 489,
          "function": "call_user_func"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php",
          "line": 259,
          "function": "triggerListeners",
          "class": "Laminas\\EventManager\\EventManager",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php",
          "line": 115,
          "function": "triggerEventUntil",
          "class": "Laminas\\EventManager\\EventManager",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/Controller/AbstractRestfulController.php",
          "line": 299,
          "function": "dispatch",
          "class": "Laminas\\Mvc\\Controller\\AbstractController",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/DispatchListener.php",
          "line": 117,
          "function": "dispatch",
          "class": "Laminas\\Mvc\\Controller\\AbstractRestfulController",
          "type": "->"
        },
        {
          "function": "onDispatch",
          "class": "Laminas\\Mvc\\DispatchListener",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php",
          "line": 489,
          "function": "call_user_func"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-eventmanager/src/EventManager.php",
          "line": 259,
          "function": "triggerListeners",
          "class": "Laminas\\EventManager\\EventManager",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/vendor/laminas/laminas-mvc/src/Application.php",
          "line": 339,
          "function": "triggerEventUntil",
          "class": "Laminas\\EventManager\\EventManager",
          "type": "->"
        },
        {
          "file": "/var/www/shipwire.www/swclient/public/index.php",
          "line": 15,
          "function": "run",
          "class": "Laminas\\Mvc\\Application",
          "type": "->"
        }
      ]
    },
    "moreInformation": []
  },
  "state": []
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions