curl -X POST "https://api.actiwapi.com/api/external/messages/send-image" \
-H "Content-Type: application/json" \
-H "X-API-Key: {apiKey}"
-d '{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}'
async function callActiwapi() {
const res = await fetch("https://api.actiwapi.com/api/external/messages/send-image", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "{apiKey}"
},
body: JSON.stringify({
"sessionId": "uuid",
"phone": "919876543210",
"mediaUrl": "https://cdn.example.com/offer.jpg",
"caption": "This week’s offer"
}),
});
if (!res.ok) {
throw new Error(await res.text());
}
const data = await res.json();
console.log(data);
}
callActiwapi();
import fetch from "node-fetch";
const res = await fetch("https://api.actiwapi.com/api/external/messages/send-image", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "{apiKey}"
},
body: JSON.stringify({
"sessionId": "uuid",
"phone": "919876543210",
"mediaUrl": "https://cdn.example.com/offer.jpg",
"caption": "This week’s offer"
}),
});
const data = await res.json();
console.log(data);
import requests
response = requests.post(
"https://api.actiwapi.com/api/external/messages/send-image",
headers={
"Content-Type": "application/json",
"X-API-Key": "{apiKey}",
},
json={
"sessionId": "uuid",
"phone": "919876543210",
"mediaUrl": "https://cdn.example.com/offer.jpg",
"caption": "This week’s offer"
},
)
print(response.json())
require "net/http"
require "uri"
uri = URI("https://api.actiwapi.com/api/external/messages/send-image")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
request = Net::HTTP::Post.new(uri)
request["Content-Type"] = "application/json"
request["X-API-Key"] = "{apiKey}"
request.body = "{ \"sessionId\": \"uuid\", \"phone\": \"919876543210\", \"mediaUrl\": \"https://cdn.example.com/offer.jpg\", \"caption\": \"This week’s offer\"}"
response = http.request(request)
puts response.body
$ch = curl_init("https://api.actiwapi.com/api/external/messages/send-image");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: {apiKey}"
],
CURLOPT_POSTFIELDS => '{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}',
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
<?php
use Illuminate\Support\Facades\Http;
$headers = [
'Content-Type' => 'application/json',
'X-API-Key' => '{apiKey}',
];
$response = Http::withHeaders($headers)->post("https://api.actiwapi.com/api/external/messages/send-image", json_decode('{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}', true));
$response->throw();
$data = $response->json();
dump($data);
using System.Net.Http;
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.TryAddWithoutValidation("X-API-Key", "{apiKey}");
var url = "https://api.actiwapi.com/api/external/messages/send-image";
var content = new StringContent("""
{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}
""", Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
// .NET 8 — IHttpClientFactory style
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient("Actiwapi", client =>
{
client.DefaultRequestHeaders.TryAddWithoutValidation("X-API-Key", "{apiKey}");
});
var app = builder.Build();
app.MapPost("/proxy", async (IHttpClientFactory factory) =>
{
var client = factory.CreateClient("Actiwapi");
var content = new StringContent("""
{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}
""", Encoding.UTF8, "application/json");
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.actiwapi.com/api/external/messages/send-image")
{
Content = content,
};
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
return Results.Content(await response.Content.ReadAsStringAsync(), "application/json");
});
app.Run();
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{ "sessionId": "uuid", "phone": "919876543210", "mediaUrl": "https://cdn.example.com/offer.jpg", "caption": "This week’s offer"}`)
req, err := http.NewRequest("POST", "https://api.actiwapi.com/api/external/messages/send-image", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "{apiKey}")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.actiwapi.com/api/external/messages/send-image"))
.method("POST", HttpRequest.BodyPublishers.ofString("{ \"sessionId\": \"uuid\", \"phone\": \"919876543210\", \"mediaUrl\": \"https://cdn.example.com/offer.jpg\", \"caption\": \"This week’s offer\"}"))
.header("Content-Type", "application/json")
.header("X-API-Key", "{apiKey}")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());