Admin Users
Admin Users
Create a new admin user
To create a new admin user, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication. See Object Definitions for more information on the Admin object.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"Username\": \"ut dolore non fugiat\",
\"Email\": \"est irure incididunt laborum\",
\"Name\": \"ali\",
\"Password\": \"aute m\",
\"AdminId\": -85630586,
\"ExternalId\": \"nisi elit\",
\"AdminPermissionsList\": []
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using (var content = new StringContent("{ \"Username\": \"ut dolore non fugiat\", \"Email\": \"est irure incididunt laborum\", \"Name\": \"ali\", \"Password\": \"aute m\", \"AdminId\": -85630586, \"ExternalId\": \"nisi elit\", \"AdminPermissionsList\": []}", System.Text.Encoding.Default, "application/json"))
{
using (var response = await httpClient.PostAsync("3dCartWebAPI/v1/Admins", content))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
}
var request = new XMLHttpRequest();
request.open('POST', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'Username': 'ut dolore non fugiat',
'Email': 'est irure incididunt laborum',
'Name': 'ali',
'Password': 'aute m',
'AdminId': -85630586,
'ExternalId': 'nisi elit',
'AdminPermissionsList': []
};
request.send(JSON.stringify(body));
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
values = '{
"Username": "ut dolore non fugiat",
"Email": "est irure incididunt laborum",
"Name": "ali",
"Password": "aute m",
"AdminId": -85630586,
"ExternalId": "nisi elit",
"AdminPermissionsList": []
}'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.post 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins', values, headers
puts response
from urllib2 import Request, urlopen
values = """
{
"Username": "ut dolore non fugiat",
"Email": "est irure incididunt laborum",
"Name": "ali",
"Password": "aute m",
"AdminId": -85630586,
"ExternalId": "nisi elit",
"AdminPermissionsList": []
}
"""
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins', data=values, headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this:
[
{
"Key":"AdminId",
"Value":"1234",
"Status":"201",
"Message":"Created successfully",
}
]
This method is used to add a new Admin User to the store. See Object Definitions for more information on the Admin object.
HTTP Request
POST https://apirest.3dcart.com/3dCartWebAPI/v2/Admins
Responses and Errors
Response Code | Description |
---|---|
201 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
Retrieve a list of admin users
To retrieve a list of admin users, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins?limit=&offset=&name=&username=&external_id=&countonly=");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Admins"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('GET', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins?limit=&offset=&name=&username=&external_id=&countonly=');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins?limit=&offset=&name=&username=&external_id=&countonly=', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins?limit=&offset=&name=&username=&external_id=&countonly=', headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this (See Object Definitions for more information on the Admin object):
[
{
"AdminId": 1,
"Username": "sample string 1",
"Email": "sample string 2",
"Name": "sample string 3",
"ExternalId": "sample string 4",
"Lastlogin": "04/12/2019 11:48",
"AdminPermissionsList": [
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
},
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
},
{
"AdminId": 1,
"Username": "sample string 1",
"Email": "sample string 2",
"Name": "sample string 3",
"ExternalId": "sample string 4",
"Lastlogin": "04/12/2019 11:48",
"AdminPermissionsList": [
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
},
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
}
]
See Object Definitions for more information on the Admin object.
HTTP Request
GET https://apirest.3dcart.com/3dCartWebAPI/v2/Admins
URL Parameters
Parameters | Required | Description |
---|---|---|
limit | optional | Maximum number of items that can be returned. |
offset | optional | Starting point for the return data. |
countonly | optional | Count the number of rows only. |
name | optional | Name of the admin user. |
username | optional | Username of the admin user. |
external_id | optional | Admin external id. |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | The admin user was not found. |
Retrieve a specific admin user by id
To retrieve a specific admin user by id, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Admins/{id}"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('GET', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this (See Object Definitions for more information on the Admin object):
[
{
"AdminId": 1,
"Username": "sample string 1",
"Email": "sample string 2",
"Name": "sample string 3",
"ExternalId": "sample string 4",
"Lastlogin": "04/12/2019 11:48",
"AdminPermissionsList": [
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
},
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
},
{
"AdminId": 1,
"Username": "sample string 1",
"Email": "sample string 2",
"Name": "sample string 3",
"ExternalId": "sample string 4",
"Lastlogin": "04/12/2019 11:48",
"AdminPermissionsList": [
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
},
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
}
]
See Object Definitions for more information on the Admin object.
HTTP Request
GET https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}
URL Parameters
Parameters | Required | Description |
---|---|---|
id | required | The id of the admin user to retrieve. |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | The admin user was not found. |
Update a specific admin user by id
To update a specific admin user by id, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication. See Object Definitions for more information on the Admin object.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"AdminId\": -8588494,
\"Username\": \"aute proident sunt anim ad\",
\"Email\": \"occaecat ipsum\",
\"Name\": \"Lorem\",
\"Password\": \"veniam in r\",
\"ExternalId\": \"fugiat ipsum do\",
\"AdminPermissionsList\": []
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using (var content = new StringContent("{ \"AdminId\": -8588494, \"Username\": \"aute proident sunt anim ad\", \"Email\": \"occaecat ipsum\", \"Name\": \"Lorem\", \"Password\": \"veniam in r\", \"ExternalId\": \"fugiat ipsum do\", \"AdminPermissionsList\": []}", System.Text.Encoding.Default, "application/json"))
{
using (var response = await httpClient.PutAsync("3dCartWebAPI/v1/Admins/{id}", content))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
}
var request = new XMLHttpRequest();
request.open('PUT', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'AdminId': -8588494,
'Username': 'aute proident sunt anim ad',
'Email': 'occaecat ipsum',
'Name': 'Lorem',
'Password': 'veniam in r',
'ExternalId': 'fugiat ipsum do',
'AdminPermissionsList': []
};
request.send(JSON.stringify(body));
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
values = '{
"AdminId": -8588494,
"Username": "aute proident sunt anim ad",
"Email": "occaecat ipsum",
"Name": "Lorem",
"Password": "veniam in r",
"ExternalId": "fugiat ipsum do",
"AdminPermissionsList": []
}'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.put 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', values, headers
puts response
from urllib2 import Request, urlopen
values = """
{
"AdminId": -8588494,
"Username": "aute proident sunt anim ad",
"Email": "occaecat ipsum",
"Name": "Lorem",
"Password": "veniam in r",
"ExternalId": "fugiat ipsum do",
"AdminPermissionsList": []
}
"""
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', data=values, headers=headers)
request.get_method = lambda: 'PUT'
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this:
[
{
"Key":"AdminId",
"Value":"1234",
"Status":"200",
"Message":"updated successfully",
}
]
See Object Definitions for more information on the Admin object.
HTTP Request
PUT https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}
URL Parameters
Parameters | Required | Description |
---|---|---|
id | required | The id of the admin user to update. |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | The admin user was not found. |
Delete an admin user
To delete an admin user, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.DeleteAsync("3dCartWebAPI/v1/Admins/{id}"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('DELETE', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.delete 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}', headers=headers)
request.get_method = lambda: 'DELETE'
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this:
[
{
"Key":"AdminId",
"Value":"1234",
"Status":"200",
"Message":"Deleted successfully",
}
]
See Object Definitions for more information on the Admin object.
HTTP Request
DELETE https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}
URL Parameters
Parameters | Required | Description |
---|---|---|
id | required | The id of the admin user to delete. |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | The admin user was not found. |
Admin Permissions
The Admin Permissions methods allow all available permissions, or all permissions assigned to a specific user, to be viewed. Use the Admin Users methods to add/update user permissions.
Retrieve a list of admin user permissions
To retrieve a list of admin user permissions, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions?limit=&offset=§ion=&action=&countonly=");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/AdminPermissions"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('GET', 'https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions?limit=&offset=§ion=&action=&countonly=');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions?limit=&offset=§ion=&action=&countonly=', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions?limit=&offset=§ion=&action=&countonly=', headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this:
[
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
},
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
This method allows you to see a full list of all available permissions. See Object Definitions for more information on the AdminPermission object.
HTTP Request
GET https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions
URL Parameters
Parameters | Required | Description |
---|---|---|
limit | optional | Maximum number of items that can be returned. |
offset | optional | Starting point for the return data. |
countonly | optional | Count the number of rows only. |
section | optional | Admin permission section (e.g. Orders or Products). |
action | optional | Admin permission action (e.g. view or edit). |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | No admin permissions found. |
Retrieve a specific permission by id
To retrieve a specific permission by id, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions/{id}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/AdminPermissions/{id}"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('GET', 'https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions/{id}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions/{id}', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions/{id}', headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this:
[
{
"Id": 1,
"Section": "sample string 1",
"Action": "sample string 2"
}
]
See Object Definitions for more information on the AdminPermission object.
HTTP Request
GET https://apirest.3dcart.com/3dCartWebAPI/v2/AdminPermissions/{id}
URL Parameters
Parameters | Required | Description |
---|---|---|
id | required | The id of the permission to retrieve . |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |
404 | No admin permissions found. |
Login Tokens
Retrieve a login token for an admin user
To retrieve a login token for an admin user, use the code below. Make sure to add your Secure URL, Private Key, and Token as described in Authentication.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}/LoginToken?targetpage=");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json",
"SecureURL: ",
"PrivateKey: ",
"Token: "
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://apirest.3dcart.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("secureurl", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("privatekey", "");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("token", "");
using(var response = await httpClient.GetAsync("3dCartWebAPI/v1/Admins/{id}/LoginToken"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
var request = new XMLHttpRequest();
request.open('GET', 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}/LoginToken?targetpage=');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('SecureURL', '');
request.setRequestHeader('PrivateKey', '');
request.setRequestHeader('Token', '');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
request.send();
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rest_client'
headers = {
:content_type => 'application/json',
:accept => 'application/json',
:secureurl => '',
:privatekey => '',
:token => ''
}
response = RestClient.get 'https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}/LoginToken?targetpage=', headers
puts response
from urllib2 import Request, urlopen
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'SecureURL': '',
'PrivateKey': '',
'Token': ''
}
request = Request('https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}/LoginToken?targetpage=', headers=headers)
response_body = urlopen(request).read()
print response_body
The above request will receive a response with JSON structured like this (See Object Definitions for more information on the AdminLoginToken object):
{
"Token": "sample string 1",
"Loginurl": "sample string 2",
"Expiration": "04/16/2019 21:34"
}
See Object Definitions for more information on the AdminLoginToken object.
HTTP Request
GET https://apirest.3dcart.com/3dCartWebAPI/v2/Admins/{id}/LoginToken
URL Parameters
Parameters | Required | Description |
---|---|---|
id | required | The id of the admin user to retrieve a login token for. |
targetpage | optional | The URL to redirect the user to after login. |
Responses and Errors
Response Code | Description |
---|---|
200 | Successful response code. |
400 | Bad request. Check request headers/parameters/body for errors. |
401 | Authentication failure. The PrivateKey/Token/SecureURL combination is invalid, or the application scope does not have the correct read/write privileges. |