Difference between revisions of "NATS4 REST API Update Member Status"
From TMM Wiki
Jump to navigationJump to search (Created page with "{{NATS4 Manual | show_api_admin_section = true }} == '''PUT /member/updatestatus''' == '''Description''' *The /member/updatestatus endpoint allows you to update a members st...") |
|||
Line 58: | Line 58: | ||
); | ); | ||
− | $url = 'http:// | + | $url = 'http://domain/api/member/updatestatus'; |
$headers = array( | $headers = array( | ||
Line 84: | Line 84: | ||
import json | import json | ||
− | url = 'http:// | + | url = 'http://domain/api/member/updatestatus' |
payload = { | payload = { | ||
Line 113: | Line 113: | ||
var options = { | var options = { | ||
− | url: 'http:// | + | url: 'http://domain/api/member/updatestatus', |
method: 'PUT', | method: 'PUT', | ||
form: data, | form: data, | ||
Line 139: | Line 139: | ||
'''Curl''' | '''Curl''' | ||
<pre> | <pre> | ||
− | curl -X PUT 'http:// | + | curl -X PUT 'http://domain/api/member/updatestatus' -H "api_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_username: tmm1phrvezsbu" -H "Content-Type: application/x-www-form-urlencoded" -d 'memberid=191&status=1' |
</pre> | </pre> | ||
[[Category:NATS4 API Articles]] | [[Category:NATS4 API Articles]] |
Latest revision as of 23:11, 15 March 2015
PUT /member/updatestatus
Description
- The /member/updatestatus endpoint allows you to update a members status to either active or inactive.
- Note, this API call requires that you have ['LICENSE']['MOD_UPDATE_MEMBER_STATUS_API'] set to 'YES'. Please contact a support tech if you need assistance with setting this NATS configuration variable.
Resource URL
- http://domain/api/v1/member/updatestatus
- Replace domain with the nats domain
- PUT
Response Format
- JSON
- HTTP headers
Parameters
Paremeters must be sent with the request body. The examples below show the parameters sent as x-www-form-urlencoded.
- memberid: The ID of the member to update
- type: int
- required
- status: The ID of the status to update to. The status could either be 1 or 2.
- type: int
- required
Example Request
PUT
http://domain/api/v1/member/updatestatus
- Response:
{ "SUCCESS": "The status of memberid: 191 was changed to: 1" }
Example Code
PHP
<?php $curl = curl_init(); $data = array( 'memberid' => 162, 'status' => 1, ); $url = 'http://domain/api/member/updatestatus'; $headers = array( 'api_key: 44b5498dbcb481a0d00b404c0169af62', 'api_username: tmm1phrvezsbu' ); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_URL, $url); $resp = curl_exec($curl); //dumps an associative array representation of the json var_dump(json_decode($resp, true)); // Close request to clear up some resources curl_close($curl); ?>
Python
- This example requires pip and the request library which can be installed via pip by: 'pip install requests'
import requests import json url = 'http://domain/api/member/updatestatus' payload = { 'memberid': 191, 'status': 1 } headers = { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } res = requests.put(url, data=payload, headers=headers) print res.json()
node.js
- This example requires npm and the request module which can be installed via npm by: 'npm install request'
var request = require('request'); data = { 'memberid': 191, 'status': 1 } var options = { url: 'http://domain/api/member/updatestatus', method: 'PUT', form: data, json: true, headers: { 'api_key': '44b5498dbcb481a0d00b404c0169af62', 'api_username': 'tmm1phrvezsbu' } }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } else{ console.log(body); } } request(options, callback);
Curl
curl -X PUT 'http://domain/api/member/updatestatus' -H "api_key: 44b5498dbcb481a0d00b404c0169af62" -H "api_username: tmm1phrvezsbu" -H "Content-Type: application/x-www-form-urlencoded" -d 'memberid=191&status=1'