Quickstart: Query API

The task demonstrates how to retrieve an access token and use the Query API to request the role(s) assigned to the account associated with the token.
The example uses the curl command-line utility to demonstrate how to make the test request. Detailed information about the steps are available in these topics:
Note: These examples use a randomly generated client id, client secret, and token values. Replace the example values with the ones you obtain.
  1. Obtain your API keys from Medallia
    1. Create an application account and create an OAuth account for you application (per Creating an OAuth client for API access). You need the client ID and client secret to authorize access and provide an access token.

    2. Identify the resource endpoint to use to make queries. Verify the query URL and endpoint (for details about this URL and for determining the URL for the sandbox, see API hosts).

  2. Request an access token
    In a UNIX command-line, use this curl invocation. Substitute your company URL for instance.medallia.com, insert your company name, and use the client ID and secret provided:
    $ curl https://instance.medallia.com/oauth/company/token \
    >    -X POST \
    >    -u 'clientID:clientSecret' \
    >    -d grant_type=client_credentials 
    The OAuth server returns a JSON value like this:
    {"access_token":"40d182e5dcbef32ce34b737ba5d4","token_type":"Bearer","expires_in":3600}

    Once you have the access token (access_token value), you can make a query request.

  3. Make a query using the access token
    Make the query request using the access token as the Bearer value. Substitute the URL and endpoint provided to you. In this example, the URL is instance-company.apis.medallia.com:
    $ curl -H 'Authorization: Bearer 40d182e5dcbef32ce34b737ba5d4' \
    > -H 'Content-Type: application/json' \ 
    > "https://instance-company.apis.medallia.com/data/v0/query" \ 
    > --data '{"query":"query {me {roles {id name}}}\n","variables":{}}' 
    The query returns the roles assigned to the OAuth account.
    {"data":{"me":{"roles":[{"id":"139085","name":"API User"}]}},"errors":null,"_links":null,"_allowed":["POST","GET"]}
Once you get the response containing the roles for the account, you are ready to use the Query API.