Puts the application data for a project.
Header Key | Description | Example |
---|---|---|
Authorization | The Authorization header for this endpoint. The value must be the token from the /v3/auth/tokens/get endpoint and given using the Bearer pattern. | Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdW... |
Name | Type | Description |
---|---|---|
projectCode | string | The code of the project. |
Name | Type | Description |
---|---|---|
* projectId | uuid | The ID of the project. |
* surveyTitleLang | object | A mapping of language codes to survey names so as to localize survey names. |
* projectApiUrl | string | The URL of the server where the API for this project is hosted. |
branding | object | The theme rules for customizing the branding of the app after logging into this project. |
* loginStrategy | object | The strategy for how subjects in this project are meant to log in and take assessments. |
* assessmentStrategy | object | The strategy for how assessments in this project are to be handled. |
* profileStrategy | object | The strategy for how the subject's profile screen is managed. |
* notificationsEnabled | boolean | Whether push notifications are enabled for this project. |
* testSubjects | array<string> | A list of regex-based subject names to recognize as test data and exclude from reports, etc. |
A successful response
Field Name | Type | Description |
---|---|---|
message | string | "OK" |
curl \
-X PUT "https://rest.eus.canaryspeech.com/v2/meta/put-project-data/${PROJECT_CODE}" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" \
-d "{ \"projectId\": \"12345678-1234-abcd-5678-12345678\", \"surveyTitleLang\": { }, \"projectApiUrl\": \"abc123\", \"loginStrategy\": { }, \"assessmentStrategy\": { }, \"profileStrategy\": { }, \"notificationsEnabled\": true, \"testSubjects\": [ \"abc123\", \"abc123\" ] }"
function putV2MetaPutProjectData() {
const projectCode = 'abc123';
const url = `https://rest.eus.canaryspeech.com/v2/meta/put-project-data/${projectCode}`;
const headers = {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
const body = {
projectId: '12345678-1234-abcd-5678-12345678',
surveyTitleLang: { },
projectApiUrl: 'abc123',
loginStrategy: { },
assessmentStrategy: { },
profileStrategy: { },
notificationsEnabled: true,
testSubjects: [
'abc123',
'abc123'
]
};
fetch(url, {
method: 'PUT',
headers: headers,
body: JSON.stringify(body)
}).then((response) => {
if (!response.ok) throw new Error(response.status);
return response.json()
}).then((json) => {
const { message } = json;
// ...
});
}
const https = require('https');
function putV2MetaPutProjectData() {
const projectCode = 'abc123';
const headers = {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
const body = {
projectId: '12345678-1234-abcd-5678-12345678',
surveyTitleLang: { },
projectApiUrl: 'abc123',
loginStrategy: { },
assessmentStrategy: { },
profileStrategy: { },
notificationsEnabled: true,
testSubjects: [
'abc123',
'abc123'
]
};
const options = {
hostname: 'rest.eus.canaryspeech.com',
port: 443,
path: `/v2/meta/put-project-data/${projectCode}`,
method: 'PUT',
headers: headers
};
const request = https.request(options, (response) => {
if (response.statusCode !== 200) throw new Error(response.statusCode);
response.on('data', (d) => {
const { message } = JSON.parse(d);
// ...
});
});
request.on('error', (err) => {
throw new Error(err);
});
request.write(JSON.stringify(body));
request.end();
}
const axios = require('axios').default;
async function putV2MetaPutProjectData() {
const projectCode = 'abc123';
const url = `https://rest.eus.canaryspeech.com/v2/meta/put-project-data/${projectCode}`;
const headers = {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
const body = {
projectId: '12345678-1234-abcd-5678-12345678',
surveyTitleLang: { },
projectApiUrl: 'abc123',
loginStrategy: { },
assessmentStrategy: { },
profileStrategy: { },
notificationsEnabled: true,
testSubjects: [
'abc123',
'abc123'
]
};
const response = await axios.put(url, body, { headers });
if (response.status !== 200) throw new Error(response.status);
const { message } = response.data;
// ...
}
import * as https from 'https';
function putV2MetaPutProjectData(): void {
const projectCode = 'abc123';
const headers = {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
const body = {
projectId: '12345678-1234-abcd-5678-12345678',
surveyTitleLang: { },
projectApiUrl: 'abc123',
loginStrategy: { },
assessmentStrategy: { },
profileStrategy: { },
notificationsEnabled: true,
testSubjects: [
'abc123',
'abc123'
]
};
const options = {
hostname: 'rest.eus.canaryspeech.com',
port: 443,
path: `/v2/meta/put-project-data/${projectCode}`,
method: 'PUT',
headers: headers
};
const request = https.request(options, (response) => {
if (response.statusCode !== 200) throw new Error(response.statusCode);
response.on('data', (d) => {
const { message } = JSON.parse(d) as Record<string, unknown>;
// ...
});
});
request.on('error', (err) => {
throw new Error(err);
});
request.write(JSON.stringify(body));
request.end();
}
import axios from 'axios';
async function putV2MetaPutProjectData(): Promise<void> {
const projectCode = 'abc123';
const url = `https://rest.eus.canaryspeech.com/v2/meta/put-project-data/${projectCode}`;
const headers = {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
const body = {
projectId: '12345678-1234-abcd-5678-12345678',
surveyTitleLang: { },
projectApiUrl: 'abc123',
loginStrategy: { },
assessmentStrategy: { },
profileStrategy: { },
notificationsEnabled: true,
testSubjects: [
'abc123',
'abc123'
]
};
const response = await axios.put(url, body, { headers });
if (response.status !== 200) throw new Error(response.status);
const { message } = response.data;
// ...
}
import requests
def put_v2_meta_put_project_data():
project_code = 'abc123'
url = f'https://rest.eus.canaryspeech.com/v2/meta/put-project-data/{project_code}'
headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
}
body = {
'projectId': '12345678-1234-abcd-5678-12345678',
'surveyTitleLang': {
},
'projectApiUrl': 'abc123',
'loginStrategy': {
},
'assessmentStrategy': {
},
'profileStrategy': {
},
'notificationsEnabled': True,
'testSubjects': [
'abc123',
'abc123'
]
}
response = requests.put(
url,
headers=headers,
data=body,
)
if response.status_code !== 200:
raise Exception(response.status_code)
response_obj = response.json()
message = response_obj['message']
# ...
import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.JSONParser;
import org.json.simple.JSONValue;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
public class CanarySpeechApi {
public void putV2MetaPutProjectData() {
final String projectCode = "abc123"
URI uri = new URI("https://rest.eus.canaryspeech.com/v2/meta/put-project-data/" + projectCode);
JSONObject body$surveyTitleLang = new JSONObject();
JSONObject body$loginStrategy = new JSONObject();
JSONObject body$assessmentStrategy = new JSONObject();
JSONObject body$profileStrategy = new JSONObject();
JSONArray body$testSubjects = new JSONArray();
body$testSubjects.add("abc123");
body$testSubjects.add("abc123");
JSONObject body = new JSONObject();
body.put("projectId", "12345678-1234-abcd-5678-12345678");
body.put("surveyTitleLang", body$surveyTitleLang);
body.put("projectApiUrl", "abc123");
body.put("loginStrategy", body$loginStrategy);
body.put("assessmentStrategy", body$assessmentStrategy);
body.put("profileStrategy", body$profileStrategy);
body.put("notificationsEnabled", new Boolean(true));
body.put("testSubjects", body$testSubjects);
byte[] bodyBytes = JSONValue.toJSONString(body).getBytes(StandardCharsets.UTF_8);
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.version(HttpClient.Version.HTTP_2)
.header("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
.PUT(BodyPublishers.ofByteArray(bodyBytes))
.build();
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (client.status != 200) {
throw new Exception(client.status.toString());
}
JSONParser parser = new JSONParser();
JSONObject responseBody = (JSONObject) parser.parse(client.body());
String message = (String) responseBody.get("message");
// ...
}
}
import org.json.JSONObject
import java.lang.StringBuilder
import java.net.URL
import javax.net.ssl.HttpsURLConnection
suspend fun putV2MetaPutProjectData() = runCatching {
val projectCode = "abc123"
val url = URL.create("https://rest.eus.canaryspeech.com/v2/meta/put-project-data/"${projectCode}"")
with(url.openConnection() as HttpsURLConnection) {
requestMethod = "PUT"
instanceFollowRedirects = true
setRequestProperty("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
doInput = true
setChunkedStreamingMode(0)
val body$surveyTitleLang = JSONObject()
val body$loginStrategy = JSONObject()
val body$assessmentStrategy = JSONObject()
val body$profileStrategy = JSONObject()
val body$testSubjects = JSONArray()
body$testSubjects.add(String("abc123"))
body$testSubjects.add(String("abc123"))
val body = JSONObject()
body.put("projectId", String("12345678-1234-abcd-5678-12345678"))
body.put("surveyTitleLang", body$surveyTitleLang)
body.put("projectApiUrl", String("abc123"))
body.put("loginStrategy", body$loginStrategy)
body.put("assessmentStrategy", body$assessmentStrategy)
body.put("profileStrategy", body$profileStrategy)
body.put("notificationsEnabled", Boolean(true))
body.put("testSubjects", body$testSubjects)
outputStream.bufferedWriter(Charsets.UTF_8).use {
it.write(body.toString())
it.flush()
}
doOutput = true
if (responseCode != 200) throw Error(responseMessage)
val buffer = StringBuilder()
var line: String?
inputStream.bufferedReader(Charsets.UTF-8).use {
do {
line = it.readLine()
if (line != null) buffer.appendLine(line)
} while (line != null)
}
val responseBody = JSONObject(buffer.toString())
val message = responseBody.get("message") as String
// ...
}
}
import UIKit
func putV2MetaPutProjectData() -> void {
let projectCode = "abc123"
let url = URL("https://rest.eus.canaryspeech.com/v2/meta/put-project-data/\(projectCode)")
let headers: [String: String] = [
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
]
let body: [String: Any] = [
"projectId": "12345678-1234-abcd-5678-12345678",
"surveyTitleLang": [ ],
"projectApiUrl": "abc123",
"loginStrategy": [ ],
"assessmentStrategy": [ ],
"profileStrategy": [ ],
"notificationsEnabled": true,
"testSubjects": [
"abc123",
"abc123"
]
]
var request = URLRequest(url: url)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = JSONEncoder().encode(body)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard
let data = data,
let response = response as? HTTPURLResponse,
error == nil
else {
print("error", error ?? URLError(.badServerResponse)
return
}
guard (200 ... 299) ~= response.statusCode else {
print("statusCode = \(response.statusCode)")
print("response = \(response)")
return
}
do {
let responseObj = try JSONDecoder().decode(PutV2MetaPutProjectDataResponse.self, data)
// ...
} catch {
print(error)
}
}
}
}
struct PutV2MetaPutProjectDataResponse: Decodable {
let message: String
}
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Encoding;
using System.Text.Json;
using System.Text.Json.Serialization;
public static class CanarySpeechAPI
{
public static readonly HttpClient client = new HttpClient();
public static async Task putV2MetaPutProjectData()
{
var projectCode = "abc123";
var url = "https://rest.eus.canaryspeech.com/v2/meta/put-project-data/${projectCode}\"";
var body = new Dictionary<string, dynamic> {
{ "projectId": "12345678-1234-abcd-5678-12345678" },
{ "surveyTitleLang": new Dictionary<string, dynamic> { } },
{ "projectApiUrl": "abc123" },
{ "loginStrategy": new Dictionary<string, dynamic> { } },
{ "assessmentStrategy": new Dictionary<string, dynamic> { } },
{ "profileStrategy": new Dictionary<string, dynamic> { } },
{ "notificationsEnabled": true },
{ "testSubjects": new[] {
"abc123",
"abc123"
}
};
var bodyString = JsonConvert.Serialize(body);
var request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c");
request.Content = new ByteArrayContent(Encoding.UTF8.GetBytes(bodyString));
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
var responseJson = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(responseBody);
var message = (String)responseJson["message"];
// ...
}
}
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<void> function putV2MetaPutProjectData() async {
final projectCode = 'abc123';
final uri = Uri.https('rest.eus.canaryspeech.com', 'v2/meta/put-project-data/$projectCode', queryParams);
final headers = {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
};
final body = {
'projectId': '12345678-1234-abcd-5678-12345678',
'surveyTitleLang': { },
'projectApiUrl': 'abc123',
'loginStrategy': { },
'assessmentStrategy': { },
'profileStrategy': { },
'notificationsEnabled': true,
'testSubjects': [
'abc123',
'abc123'
]
};
final request = http.Request('PUT', uri);
request.headers.addAll(headers)
request.body = json.encode(body);
final client = http.Client();
try {
final responseStream = await client.send(request);
final statusCode = responseStream.statusCode;
if (statusCode < 200 || statusCode >= 300) {
throw Error(statusCode.toString());
}
final responseBytes = await responseStream.stream.toBytes();
final responseString = utf8.decode(responseBytes);
final response = json.decode(responseString);
final message = response['message'] as String;
// ...
} catch (e) {
print(e);
}
}