CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://www.narro.co/api/v1/articles");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "authorization: Bearer <access_token>");
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://www.narro.co/api/v1/articles");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Bearer <access_token>");
request.AddHeader("content-type", "application/json");
request.AddHeader("accept", "application/json");
request.AddParameter("application/json", "{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://www.narro.co/api/v1/articles"
payload := strings.NewReader("{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("accept", "application/json")
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer <access_token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}");
Request request = new Request.Builder()
.url("https://www.narro.co/api/v1/articles")
.post(body)
.addHeader("accept", "application/json")
.addHeader("content-type", "application/json")
.addHeader("authorization", "Bearer <access_token>")
.build();
Response response = client.newCall(request).execute();
HttpResponse<String> response = Unirest.post("https://www.narro.co/api/v1/articles")
.header("accept", "application/json")
.header("content-type", "application/json")
.header("authorization", "Bearer <access_token>")
.body("{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}")
.asString();
var settings = {
"async": true,
"crossDomain": true,
"url": "https://www.narro.co/api/v1/articles",
"method": "POST",
"headers": {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer <access_token>"
},
"processData": false,
"data": "{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}"
}
$.ajax(settings).done(function (response) {
console.log(response);
});
var data = JSON.stringify({
"text": "Mind your words, they are important. Speak like a human.",
"title": "My Optional, Custom Title"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://www.narro.co/api/v1/articles");
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Bearer <access_token>");
xhr.send(data);
var http = require("https");
var options = {
"method": "POST",
"hostname": "www.narro.co",
"port": null,
"path": "/api/v1/articles",
"headers": {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer <access_token>"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ text: 'Mind your words, they are important. Speak like a human.',
title: 'My Optional, Custom Title' }));
req.end();
var request = require("request");
var options = { method: 'POST',
url: 'https://www.narro.co/api/v1/articles',
headers:
{ authorization: 'Bearer <access_token>',
'content-type': 'application/json',
accept: 'application/json' },
body:
{ text: 'Mind your words, they are important. Speak like a human.',
title: 'My Optional, Custom Title' },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
var unirest = require("unirest");
var req = unirest("POST", "https://www.narro.co/api/v1/articles");
req.headers({
"authorization": "Bearer <access_token>",
"content-type": "application/json",
"accept": "application/json"
});
req.type("json");
req.send({
"text": "Mind your words, they are important. Speak like a human.",
"title": "My Optional, Custom Title"
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "https://www.narro.co/api/v1/articles" in
let headers = Header.add_list (Header.init ()) [
("accept", "application/json");
("content-type", "application/json");
("authorization", "Bearer <access_token>");
] in
let body = Cohttp_lwt_body.of_string "{\"text\": \"Mind your words, they are important. Speak like a human.\", \"title\": \"My Optional, Custom Title\"}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
curl --request POST \
--url https://www.narro.co/api/v1/articles \
--header 'accept: application/json' \
--header 'authorization: Bearer <access_token>' \
--header 'content-type: application/json' \
--data '{"text": "Mind your words, they are important. Speak like a human.", "title": "My Optional, Custom Title"}'
echo '{"text": "Mind your words, they are important. Speak like a human.", "title": "My Optional, Custom Title"}' | \
http POST https://www.narro.co/api/v1/articles \
accept:application/json \
authorization:'Bearer <access_token>' \
content-type:application/json
wget --quiet \
--method POST \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'authorization: Bearer <access_token>' \
--body-data '{"text": "Mind your words, they are important. Speak like a human.", "title": "My Optional, Custom Title"}' \
--output-document \
- https://www.narro.co/api/v1/articles
import Foundation
let headers = [
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer <access_token>"
]
let parameters = [
"text": "Mind your words, they are important. Speak like a human.",
"title": "My Optional, Custom Title"
]
let postData = NSJSONSerialization.dataWithJSONObject(parameters, options: nil, error: nil)
var request = NSMutableURLRequest(URL: NSURL(string: "https://www.narro.co/api/v1/articles")!,
cachePolicy: .UseProtocolCachePolicy,
timeoutInterval: 10.0)
request.HTTPMethod = "POST"
request.allHTTPHeaderFields = headers
request.HTTPBody = postData
let session = NSURLSession.sharedSession()
let dataTask = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
println(error)
} else {
let httpResponse = response as? NSHTTPURLResponse
println(httpResponse)
}
})
dataTask.resume()