Options

Create customer

golabekpgolabekp Member Posts: 14

I am following the example in the Wave api documentation for creating a customer and I am receiving the following error.

"Argument \"input\" of required type \"CustomerCreateInput!\" was provided the variable \"$input\" which was not provided a runtime value."

   $data='
        mutation ($input: CustomerCreateInput!) {
        customerCreate(input: $input) {
          didSucceed
          inputErrors {
            code
            message
            path
          }
          customer {
            id
            name
            firstName
            lastName
            email
            address {
              addressLine1
              addressLine2
              city
              province {
                code
                name
              }
              country {
                code
                name
              }
              postalCode
            }
            currency {
              code
            }
          }
        }
    }';

$variables='{"input": {
          "businessId":'.$businessId.',
          "name": "Santa",
          "firstName": "Saint",
          "lastName": "Nicholas",
          "email": "santa@example.com",
          "address": {
            "city": "North Pole",
            "postalCode": "H0H 0H0",
            "provinceCode": "CA-NU",
            "countryCode": "CA"
          },
          "currency": "CAD"
        }
    }';

    $apiBody=json_encode(array(
      'query'=>$data,
      'variables'=>$variables));

Comments

  • Options
    RobVGRobVG Member Posts: 53 admin

    Hi @golabekp,

    I tried putting your query in the GraphQL Playground, and I suspect the problem is missing " around the .$businessId. variable.

    To help debug the issue, check what the resulting $variables content is (that it is valid JSON). For your example, I would expect something like:

    {
      "input": {
        "businessId": "MY_BUSINESS_ID",
        "name": "Santa",
        "firstName": "Saint",
        "lastName": "Nicholas",
        "email": "santa@example.com",
        "address": {
          "city": "North Pole",
          "postalCode": "H0H 0H0",
          "provinceCode": "CA-NU",
          "countryCode": "CA"
        },
        "currency": "CAD"
      }
    }
    

    Hope that helps,
    Rob

    edited July 15, 2020
  • Options
    golabekpgolabekp Member Posts: 14

    Hi @RobVG,

    Thanks the issue was that the variables were structured as a string and not an array I fixed it by
    adding the following:
    $variables=array('input'=>$var);

  • Options
    ServiceNodeServiceNode Member Posts: 1

    Is there a full list of operation variables available for the create customer mutation, beyond
    "name", "firstName", "lastName", "email", "address", and "currency"?
    Such as Phone, Account number, Fax, Mobile, Toll-free, Website, and Internal notes?
    Thank you!

  • Options
    AngelaCAngelaC Member Posts: 12 admin

    Hi @ServiceNode,

    You can check out our API Reference for the full list of input parameters :smile:

    edited March 23, 2021
Sign In or Register to comment.