Update global variable


Once you created a global variable, you can update its content with simple HTTP request.

To access a specific one, you will need its unique id that is returned during creating or listing.

PUT

/global-variables/:id

Data
Type
Description
name
string
Updated name
integer_content
integer
Updated integer content
text_content
string
Updated text content
curl -X PUT -H "Authorization: Token <your_64_char_api_key>" -H "Content-Type: application/json" -d '{
  "text_content": "February Promotions"
}' "https://<your_app_subdomain>.user.com/api/public/global-variables/:id/"
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://<your_app_subdomain>.user.com/api/public/global-variables/:id/",
  "method": "PUT",
  "headers": {
    "authorization": "Token <your_64_char_api_key>",
    "content-type": "application/json"
  },
  "processData": false,
  "data": "{\n  \"text_conent\": \"February Promotions\"\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = JSON.stringify({
  "text_content": "February Promotions"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://<your_app_subdomain>.user.com/api/public/global-variables/:id/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
var request = require("request");

var options = { method: 'PUT',
  url: 'https://<your_app_subdomain>.user.com/api/public/global-variables/:id/',
  headers:
   { 'content-type': 'application/json',
     authorization: 'Token <your_64_char_api_key>' },
  body: { text_content: 'February Promotions' },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/global-variables/:id/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "{\n \"text_content\": \"February Promotions\"\n}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Token <your_64_char_api_key>",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://<your_app_subdomain>.user.com/api/public/global-variables/:id"

payload = "{\n \"text_content\": \"February Promotions\"\n}"
headers = {
    'authorization': "Token <your_64_char_api_key>",
    'content-type': "application/json"
    }

response = requests.request("PUT", url, data=payload, headers=headers)

print(response.text)
import requests

url = "https://<your_app_subdomain>.user.com/api/public/global-variables/:id"

payload = {
    "text_content": "February Promotions"
}

headers = {
    "authorization": "Token <your_64_char_api_key>",
    "content-type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json)