Echo
Description
Returns any value passed to the function. This information can be useful for debugging.
Resource URL
GET rws/api/v{apiVersion}/echo/{param}
Request Parameters
Parameter | Description |
---|---|
apiVersion |
The version number for this API. The current version for all functions is 1. |
param | The string you want to echo. |
Response Parameters
Return Value | Description |
---|---|
context | The string that you passed into the function. |
Request Example
Make sure to use your own user credentials. See Authentication for information about creating an authorization header.
curl -X GET --header "Accept: application/json" --header "Authorization: Basic <YOUR-ENCRYPTED-CREDENTIALS>" "https://rws-jpotest.jasper.com/rws/api/v1/echo/hello-world"
Response Example
{
"context": "hello-world"
}
Code Samples
Make sure to use the Control Center sandbox URL and your own user credentials.
import requests
import json
import base64
cobrandURL=input("Cobrand URL: ")
params = input("params: ")
url = 'https://'+cobrandURL+'/rws/api/v1/echo/'+params
myResponse = requests.get(url,auth=(input("username: "),input("api_key: ")))
# For successful API call, response code will be 200 (OK)
if(myResponse.ok):
# Loading the response data into a dict variable
# json.loads takes in only binary or string variables so using content to fetch binary content
# Loads (Load String) takes a Json file and converts into python data structure (dict or list, depending on JSON)
jData = json.loads(myResponse.content)
print(jData)
print("The response contains {0} properties".format(jData))
print("\n")
for key in jData:
print (key + " : " + jData[key])
else:
# If response code is not ok (200), print the resulting http error code with description
print("Failure")
myResponse.raise_for_status()
var request = require('request');
var body = [];
request.get('https://<your-base-URL>/rws/api/v1/echo/hello%20world!').auth('username', 'password', false)
.on('error', function(error){
console.log('Error:', error);
})
.on('response', function(response) {
console.log(response.statusCode); // return statusCode
console.log(response.headers['content-type']); // return contentType
})
.on('data',function(chunk){
body.push(chunk);
})
.on('end',function(){
body = Buffer.concat(body).toString();
console.log(body);
});
#!/usr/bin/ruby -w
require 'rest-client'
require 'json'
url = 'https://<your-base-URL>/rws/api/v1/echo/hello%20World'
response = RestClient.get(url)
puts JSON.parse(response)
Errors
Error Code | HTTP Code | Error Message |
---|---|---|
10000001 | 401 |
Invalid credentials. Description: Control Center uses this error message when the API credentials are invalid or when the IP address is not within the allowed range. |
10000011 | 400 |
One or more required fields are missing. |
10000024 | 400 | Invalid apiVersion. |
30000001 | 500 | Unknown server error. |