POST
/api/v1_2/documents/:document_id/commentsCreates new comment for particular document.
Please check example request body to see required structure.
Path parameters
| Name | Example | Description |
|---|---|---|
document_id |
— | — |
Request body
{
"comment": {
"text": "new comment"
}
}Code examples
curl --request POST 'https://app.datamolino.com/api/v1_2/documents/98765/comments' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer demo_access_token' \
--data '{
"comment": {
"text": "new comment"
}
}'POST /api/v1_2/documents/98765/comments HTTP/1.1
Host: app.datamolino.com
Content-Type: application/json
Authorization: Bearer demo_access_token
{
"comment": {
"text": "new comment"
}
}const response = await fetch("https://app.datamolino.com/api/v1_2/documents/98765/comments", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
},
body: JSON.stringify({
"comment": {
"text": "new comment"
}
}),
});
const data = await response.json();import axios from "axios";
const response = await axios({
method: "post",
url: "https://app.datamolino.com/api/v1_2/documents/98765/comments",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
},
data: {
"comment": {
"text": "new comment"
}
}
});
console.log(response.data);import requests
url = "https://app.datamolino.com/api/v1_2/documents/98765/comments"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
}
payload = {
"comment": {
"text": "new comment"
}
}
response = requests.request("POST", url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())require 'json'
require 'net/http'
uri = URI("https://app.datamolino.com/api/v1_2/documents/98765/comments")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer demo_access_token"
request.body = <<~JSON
{
"comment": {
"text": "new comment"
}
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
http.request(request)
end
puts JSON.parse(response.body)# app/services/datamolino_client.rb
require 'json'
require 'net/http'
class DatamolinoClient
BASE_URL = "https://app.datamolino.com"
def initialize(access_token: Rails.application.credentials.dig(:datamolino, :access_token))
@access_token = access_token
end
def request_create_comment
uri = URI("#{BASE_URL}/api/v1_2/documents/98765/comments")
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{@access_token}"
request.body = <<~JSON
{
"comment": {
"text": "new comment"
}
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
JSON.parse(response.body)
end
end<?php
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'https://app.datamolino.com/api/v1_2/documents/98765/comments', [
'headers' => json_decode('{"Content-Type":"application/json","Authorization":"Bearer demo_access_token"}', true),
'json' => json_decode('{"comment":{"text":"new comment"}}', true)
]);
echo $response->getBody();OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create("{\n \"comment\": {\n \"text\": \"new comment\"\n }\n}", MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://app.datamolino.com/api/v1_2/documents/98765/comments")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer demo_access_token")
.method("POST", body)
.build();
Response response = client.newCall(request).execute();using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://app.datamolino.com/api/v1_2/documents/98765/comments");
request.Headers.Add("Authorization", "Bearer demo_access_token");
request.Content = new StringContent("{\n \"comment\": {\n \"text\": \"new comment\"\n }\n}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());client := &http.Client{}
req, err := http.NewRequest("POST", "https://app.datamolino.com/api/v1_2/documents/98765/comments", strings.NewReader("{\n \"comment\": {\n \"text\": \"new comment\"\n }\n}"))
if err != nil { panic(err) }
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer demo_access_token")
res, err := client.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil { panic(err) }
fmt.Println(string(body))import Foundation
var request = URLRequest(url: URL(string: "https://app.datamolino.com/api/v1_2/documents/98765/comments")!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("Bearer demo_access_token", forHTTPHeaderField: "Authorization")
request.httpBody = "{\n \"comment\": {\n \"text\": \"new comment\"\n }\n}".data(using: .utf8)
let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)Responses
201 Created
Content type: application/json
{
"comment": {
"uuid": "7f3a2d4e-9a1b-4c6d-8e0f-123456789abc"
}
}