Psycholinguistic Text Analytics
POST
Communication & Tonality
{{baseUrl}}/communication
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/communication");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/communication" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/communication"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/communication"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/communication");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/communication"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/communication HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/communication")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/communication"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/communication")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/communication")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/communication');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/communication',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/communication';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/communication',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/communication")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/communication',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/communication',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/communication');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/communication',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/communication';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/communication"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/communication" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/communication",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/communication', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/communication');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/communication');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/communication' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/communication' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/communication", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/communication"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/communication"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/communication")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/communication') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/communication";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/communication \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/communication \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/communication
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/communication")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Emotion Analysis (POST)
{{baseUrl}}/emotion
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/emotion");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/emotion" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/emotion"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/emotion"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/emotion");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/emotion"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/emotion HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/emotion")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/emotion"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/emotion")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/emotion")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/emotion');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/emotion',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/emotion';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/emotion',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/emotion")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/emotion',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/emotion',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/emotion');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/emotion',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/emotion';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/emotion"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/emotion" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/emotion",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/emotion', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/emotion');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/emotion');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/emotion' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/emotion' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/emotion", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/emotion"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/emotion"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/emotion")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/emotion') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/emotion";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/emotion \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/emotion \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/emotion
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/emotion")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Emotion Analysis
{{baseUrl}}/ekman-emotion
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/ekman-emotion");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/ekman-emotion" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/ekman-emotion"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/ekman-emotion"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/ekman-emotion");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/ekman-emotion"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/ekman-emotion HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/ekman-emotion")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/ekman-emotion"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/ekman-emotion")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/ekman-emotion")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/ekman-emotion');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/ekman-emotion',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/ekman-emotion';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/ekman-emotion',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/ekman-emotion")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/ekman-emotion',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/ekman-emotion',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/ekman-emotion');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/ekman-emotion',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/ekman-emotion';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/ekman-emotion"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/ekman-emotion" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/ekman-emotion",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/ekman-emotion', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/ekman-emotion');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/ekman-emotion');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/ekman-emotion' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/ekman-emotion' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/ekman-emotion", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/ekman-emotion"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/ekman-emotion"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/ekman-emotion")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/ekman-emotion') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/ekman-emotion";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/ekman-emotion \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/ekman-emotion \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/ekman-emotion
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/ekman-emotion")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Extracts topics and sentiments and relates them.
{{baseUrl}}/topic-sentiment
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/topic-sentiment");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/topic-sentiment" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/topic-sentiment"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/topic-sentiment"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/topic-sentiment");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/topic-sentiment"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/topic-sentiment HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/topic-sentiment")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/topic-sentiment"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/topic-sentiment")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/topic-sentiment")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/topic-sentiment');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/topic-sentiment',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/topic-sentiment';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/topic-sentiment',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/topic-sentiment")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/topic-sentiment',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/topic-sentiment',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/topic-sentiment');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/topic-sentiment',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/topic-sentiment';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/topic-sentiment"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/topic-sentiment" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/topic-sentiment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/topic-sentiment', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/topic-sentiment');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/topic-sentiment');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/topic-sentiment' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/topic-sentiment' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/topic-sentiment", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/topic-sentiment"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/topic-sentiment"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/topic-sentiment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/topic-sentiment') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/topic-sentiment";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/topic-sentiment \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/topic-sentiment \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/topic-sentiment
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/topic-sentiment")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Language Detection
{{baseUrl}}/language-detection
BODY json
[
{
"id": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/language-detection");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/language-detection" {:content-type :json
:form-params [{:id ""
:text ""}]})
require "http/client"
url = "{{baseUrl}}/language-detection"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/language-detection"),
Content = new StringContent("[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/language-detection");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/language-detection"
payload := strings.NewReader("[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/language-detection HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 40
[
{
"id": "",
"text": ""
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/language-detection")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/language-detection"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/language-detection")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/language-detection")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '',
text: ''
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/language-detection');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/language-detection',
headers: {'content-type': 'application/json'},
data: [{id: '', text: ''}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/language-detection';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"","text":""}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/language-detection',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "",\n "text": ""\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/language-detection")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/language-detection',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '', text: ''}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/language-detection',
headers: {'content-type': 'application/json'},
body: [{id: '', text: ''}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/language-detection');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '',
text: ''
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/language-detection',
headers: {'content-type': 'application/json'},
data: [{id: '', text: ''}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/language-detection';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"","text":""}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"", @"text": @"" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/language-detection"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/language-detection" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/language-detection",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '',
'text' => ''
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/language-detection', [
'body' => '[
{
"id": "",
"text": ""
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/language-detection');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '',
'text' => ''
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '',
'text' => ''
]
]));
$request->setRequestUrl('{{baseUrl}}/language-detection');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/language-detection' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "",
"text": ""
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/language-detection' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "",
"text": ""
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/language-detection", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/language-detection"
payload = [
{
"id": "",
"text": ""
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/language-detection"
payload <- "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/language-detection")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/language-detection') do |req|
req.body = "[\n {\n \"id\": \"\",\n \"text\": \"\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/language-detection";
let payload = (
json!({
"id": "",
"text": ""
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/language-detection \
--header 'content-type: application/json' \
--data '[
{
"id": "",
"text": ""
}
]'
echo '[
{
"id": "",
"text": ""
}
]' | \
http POST {{baseUrl}}/language-detection \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "",\n "text": ""\n }\n]' \
--output-document \
- {{baseUrl}}/language-detection
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "",
"text": ""
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/language-detection")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Personality Traits
{{baseUrl}}/personality
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/personality");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/personality" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/personality"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/personality"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/personality");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/personality"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/personality HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/personality")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/personality"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/personality")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/personality")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/personality');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/personality',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/personality';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/personality',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/personality")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/personality',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/personality',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/personality');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/personality',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/personality';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/personality"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/personality" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/personality",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/personality', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/personality');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/personality');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/personality' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/personality' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/personality", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/personality"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/personality"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/personality")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/personality') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/personality";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/personality \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/personality \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/personality
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/personality")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Sentiment Analysis
{{baseUrl}}/sentiment
BODY json
[
{
"id": "",
"language": "",
"text": ""
}
]
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/sentiment");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/sentiment" {:content-type :json
:form-params [{:id "1"
:language "en"
:text "I love the service"}]})
require "http/client"
url = "{{baseUrl}}/sentiment"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/sentiment"),
Content = new StringContent("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/sentiment");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/sentiment"
payload := strings.NewReader("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/sentiment HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 81
[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/sentiment")
.setHeader("content-type", "application/json")
.setBody("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/sentiment"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]");
Request request = new Request.Builder()
.url("{{baseUrl}}/sentiment")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/sentiment")
.header("content-type", "application/json")
.body("[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
.asString();
const data = JSON.stringify([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/sentiment');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/sentiment',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/sentiment';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/sentiment',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]")
val request = Request.Builder()
.url("{{baseUrl}}/sentiment")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/sentiment',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify([{id: '1', language: 'en', text: 'I love the service'}]));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/sentiment',
headers: {'content-type': 'application/json'},
body: [{id: '1', language: 'en', text: 'I love the service'}],
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/sentiment');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send([
{
id: '1',
language: 'en',
text: 'I love the service'
}
]);
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/sentiment',
headers: {'content-type': 'application/json'},
data: [{id: '1', language: 'en', text: 'I love the service'}]
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/sentiment';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '[{"id":"1","language":"en","text":"I love the service"}]'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @[ @{ @"id": @"1", @"language": @"en", @"text": @"I love the service" } ];
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/sentiment"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/sentiment" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/sentiment",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/sentiment', [
'body' => '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/sentiment');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
[
'id' => '1',
'language' => 'en',
'text' => 'I love the service'
]
]));
$request->setRequestUrl('{{baseUrl}}/sentiment');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/sentiment' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/sentiment' -Method POST -Headers $headers -ContentType 'application/json' -Body '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/sentiment", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/sentiment"
payload = [
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/sentiment"
payload <- "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/sentiment")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/sentiment') do |req|
req.body = "[\n {\n \"id\": \"1\",\n \"language\": \"en\",\n \"text\": \"I love the service\"\n }\n]"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/sentiment";
let payload = (
json!({
"id": "1",
"language": "en",
"text": "I love the service"
})
);
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/sentiment \
--header 'content-type: application/json' \
--data '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]'
echo '[
{
"id": "1",
"language": "en",
"text": "I love the service"
}
]' | \
http POST {{baseUrl}}/sentiment \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '[\n {\n "id": "1",\n "language": "en",\n "text": "I love the service"\n }\n]' \
--output-document \
- {{baseUrl}}/sentiment
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
[
"id": "1",
"language": "en",
"text": "I love the service"
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/sentiment")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()