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

Creating response json block based on the API result #768

Open
bharatid opened this issue Mar 26, 2022 · 0 comments
Open

Creating response json block based on the API result #768

bharatid opened this issue Mar 26, 2022 · 0 comments

Comments

@bharatid
Copy link

bharatid commented Mar 26, 2022

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": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant