Player Upsert API

The API Upserts the Players. The data is sent to the servers for the integration usage. The data is sent to the servers for the integration usage.

API Endpoint

The request is a POST request to the /api/integration/players endpoint.

Request Structure

POST /api/integration/players HTTP/1.1
{
data: [
{
Name: "<name>",
Email: "<email-id>",
Phone: "<mobile-number>",
Add: "<address>",
DOB: "<date-of-birth>",
Gender: "<gender>",
Refercode: "<referral-code>",
State: "<state>",
District: "<district>",
RefBy: "<code-referred-by>",
Pincode: "<pin-code-of-address>",
Country: "<country>",
User_id: "<user-id>"
}
]
}

Query

NametrueStringName of the person
EmailtrueStringEmail Id
PhonefalseNumberMobile Number
AddfalseStringLocation
DOBtrueDateDate of Birth
GendertrueStringGender(male/female)
RefercodetrueStringReferral Code for getting the benefits
StatetrueStringState of residence
DistrictfalseStringDistrict of residence
RefByfalseStringReferred by the person/organization
PincodetrueNumberPincode of the area of residence
CountrytrueStringCountry
User_idtrueStringUnique ID offered to the user

Sample Request

  • cURL
  • PHP-cUrl
  • Node-Axios
  • C#-RestSharp
  • Python-http.client
  • Java-OkHttp
  • Go
  • Ruby
  • C
  • PowerShell

curl --location --request POST 'localhost:8000/api/integration/players' --header 'token: U78FtRBfsMAnecq_q3i8J' --header 'Content-Type: application/json' --data-raw '{
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
}'

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'localhost:8000/api/integration/players',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
}',
CURLOPT_HTTPHEADER => array(
'token: U78FtRBfsMAnecq_q3i8J',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

var axios = require('axios');
var data = JSON.stringify({
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
});
var config = {
method: 'post',
url: 'localhost:8000/api/integration/players',
headers: {
'token': 'U78FtRBfsMAnecq_q3i8J',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});

var client = new RestClient("localhost:8000/api/integration/players");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("token", "U78FtRBfsMAnecq_q3i8J");
request.AddHeader("Content-Type", "application/json");
var body = @"{
" + "
" +
@" ""data"": [
" + "
" +
@" {
" + "
" +
@" ""Name"": ""abhay"",
" + "
" +
@" ""Email"": ""[email protected]"",
" + "
" +
@" ""Phone"": ""7666804987"",
" + "
" +
@" ""Add"": """",
" + "
" +
@" ""DOB"": ""24-02-1994"",
" + "
" +
@" ""Gender"": ""male"",
" + "
" +
@" ""Refercode"": """",
" + "
" +
@" ""State"": ""Maharashtra"",
" + "
" +
@" ""District"": ""Navi Mumbai"",
" + "
" +
@" ""RefBy"": """",
" + "
" +
@" ""Pincode"": ""400710"",
" + "
" +
@" ""Country"": ""India"",
" + "
" +
@" ""User_id"": ""98""
" + "
" +
@" }
" + "
" +
@" ]
" + "
" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

import http.client
import json
conn = http.client.HTTPSConnection("localhost", undefined)
payload = json.dumps({
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
})
headers = {
'token': 'U78FtRBfsMAnecq_q3i8J',
'Content-Type': 'application/json'
}
conn.request("POST", "/api/integration/players", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
}");
Request request = new Request.Builder()
.url("localhost:8000/api/integration/players")
.method("POST", body)
.addHeader("token", "U78FtRBfsMAnecq_q3i8J")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();

package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "localhost:8000/api/integration/players"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"data": [`+"
"+`
{`+"
"+`
"Name": "abhay",`+"
"+`
"Email": "[email protected]",`+"
"+`
"Phone": "7666804987",`+"
"+`
"Add": "",`+"
"+`
"DOB": "24-02-1994",`+"
"+`
"Gender": "male",`+"
"+`
"Refercode": "",`+"
"+`
"State": "Maharashtra",`+"
"+`
"District": "Navi Mumbai",`+"
"+`
"RefBy": "",`+"
"+`
"Pincode": "400710",`+"
"+`
"Country": "India",`+"
"+`
"User_id": "98"`+"
"+`
}`+"
"+`
]`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("token", "U78FtRBfsMAnecq_q3i8J")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

require "uri"
require "json"
require "net/http"
url = URI("localhost:8000/api/integration/players")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["token"] = "U78FtRBfsMAnecq_q3i8J"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
})
response = http.request(request)
puts response.read_body

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8000/api/integration/players");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "token: U78FtRBfsMAnecq_q3i8J");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{
"data": [
{
"Name": "abhay",
"Email": "[email protected]",
"Phone": "7666804987",
"Add": "",
"DOB": "24-02-1994",
"Gender": "male",
"Refercode": "",
"State": "Maharashtra",
"District": "Navi Mumbai",
"RefBy": "",
"Pincode": "400710",
"Country": "India",
"User_id": "98"
}
]
}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("token", "U78FtRBfsMAnecq_q3i8J")
$headers.Add("Content-Type", "application/json")
$body = "{
`n `"data`": [
`n {
`n `"Name`": `"abhay`",
`n `"Email`": `"[email protected]`",
`n `"Phone`": `"7666804987`",
`n `"Add`": `"`",
`n `"DOB`": `"24-02-1994`",
`n `"Gender`": `"male`",
`n `"Refercode`": `"`",
`n `"State`": `"Maharashtra`",
`n `"District`": `"Navi Mumbai`",
`n `"RefBy`": `"`",
`n `"Pincode`": `"400710`",
`n `"Country`": `"India`",
`n `"User_id`": `"98`"
`n }
`n ]
`n}"
$response = Invoke-RestMethod 'localhost:8000/api/integration/players' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

Sample Response

POST /api/integration/players HTTP/1.1
{
message: "0 new records inserted. 1 existing records updated. No user id skipped: 0",
inserted: 0,
updated: 1,
skipped: 0
}

Error Codes

200SuccessRequest Based Response
400Bad Request{ "path": "String", "error": "String" }
401Unauthorized{ "error": "String" }
500Internal server error{ "error": "String" }