Create or Update a Variable

This operation enables you to create a new service or servicecoll variable or update the value for an existing variable. The variables are associated with a specific service or service collection. This is identified with the id parameter in the request.

Note: You cannot use the MEP Expression Language inside the value of variables created or updated with this operation.

Quick facts

Method

GET

Returns

Plain text

Available

All regions

Prerequisites

You must have a MEP account provisioned with OpenMarket.

More information

See MEP Operations and Making Variable Requests.

Try It Out

If you'd like to try out this call using cURL, see Making Variable Requests, which will take you through tasks such as creating, updating, retrieving and deleting variables.

Making a Request

Definition

GET https://cmx2api.openmarket.com/variableapi/set

URL example

https://cmx2api.openmarket.com/variableapi/set?username=MyUsername&password=P4S5W0Rd&id=1A2B3C4D5E6F&scope=service&key=rewardToday&value=free+medium+coffee

Query parameters

Parameters must be URL encoded.

Parameter

Description

username

The username used to access MEP.

Required: yes

Type: string

password

The password associated with the MEP username.

Required: yes

Type: string

id

The ID of the service or service collection for which you are setting a new variable value. For example: 2A019B40EB7DB0F.

Required: yes

Type: string

scope

The variable's scope. Either:

  • service — associated with the specified service.
  • servicecoll — (service collection) accessible to all services within that collection that is global to end users.

Required: yes

Type: string

key

The variable’s key. Keys can use any character between A-Z, as well as the underscore, hyphen, and dot characters ("_ - . "). Variables are not case-sensitive.

Required: yes

Type: string

value

value The value you are setting for the variable. Values can use any of the ASCII character set.

Required: yes

Type: string

Header fields

There is no data required in the header.

Response from OpenMarket

Accepted requests

If your request is accepted, OpenMarket will return an HTTP 200 response with "OK" in the response body.

HTTP/1.1 200 OK
Date: Tue, 15 Mar 2016 18:02:57 GMT
Server: Apache-Coyote/1.1
Content-Length: 2
Content-Type: text/plain

OK

Rejected requests

If your request is rejected then the body of the response will contain a plain text description of the error. For example:

HTTP/1.1 401 Unauthorized
Date: Tue, 15 Mar 2016 11:48:56 GMT
Server: Apache-Coyote/1.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain
			
Your username and/or password is incorrect. Check and try again.

See Response error messages below for a list of the possible error messages.

Testing your integration

As variables operations do not send messages, the best way to test your integration is directly with MEP. We suggest creating a simple service, test that this works, then expand the service as required with other handlers and functionality. We recommend that you test regularly as you build your service, so that you can troubleshoot any service flow issues faster.

For more information on using each operation, see Making Variable Requests.

Troubleshooting

Response error messages

These error messages are returned in the response body when there was a problem with receiving the request.

Message

Description

The required parameter <parameter> was blank

The specified parameter is mandatory and requires a value. MEP will reject the request until it is sent with a value for the parameter.

The required parameter <parameter> was not provided

The specified parameter is missing, or has been misspelled. Add the parameter and resend.

Your request is invalid, specifically the following parameter is incorrect: <parameter>=<value>

You request contains a problem with the specified mandatory parameter that has stopped MEP from being able to process the request. If the <value> is “null”, then the parameter name is misspelled or the parameter is missing. Otherwise, the value you specified is invalid or does not match the available options. Correct the error and resend the message.

Your username and/or password is incorrect. Check and try again.

Either the username or the password parameter has not been correctly specified. Both parameters are mandatory. Check that both parameters are specified, and that you have entered the correct values for each parameter.

You do not have the necessary roles or permissions to perform the action: <description>

Your access rights in MEP do not allow you use the operation. The information in the <description> part of the response will tell you the role or permission that you are missing.