POST UploadFile Upload a file
Account
mobile + password
Accepts POST
Stores a base64 data URI on the platform and returns a public URL you can then pass to sendFile. Send this one as POST: a data URI is far too long for a query string.
POST
https://api.replier.net/UploadFile
Parameters
| Name | Type | Description |
|---|---|---|
| mobile required | string |
The mobile number the account is registered under, in international format.
Example:
447700900123
|
| password required | string |
The account password.
Example:
YOUR_ACCOUNT_PASSWORD
|
| file required | string |
The file as a data URI, complete with the data: prefix and the mime type.
Example:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...
|
Request test
sends a real request
This calls the live API with whatever you enter, so a send endpoint will
deliver a real message. Replace the placeholder credentials with your own.
Response
Request samples
curl --request POST \
--url 'https://api.replier.net/UploadFile' \
--data-urlencode 'mobile=447700900123' \
--data-urlencode 'password=YOUR_ACCOUNT_PASSWORD' \
--data-urlencode 'file=data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...'
<?php
$payload = [
'mobile' => '447700900123',
'password' => 'YOUR_ACCOUNT_PASSWORD',
'file' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.replier.net/UploadFile',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($payload),
]);
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error !== '') {
throw new RuntimeException($error);
}
$result = json_decode($response, true);
// Every endpoint answers with {"success": bool, "msg": [...]} on failure.
if (isset($result['success']) && $result['success'] === false) {
throw new RuntimeException('API error ' . implode(', ', $result['msg']));
}
print_r($result);
import requests
url = 'https://api.replier.net/UploadFile'
payload = {
'mobile': '447700900123',
'password': 'YOUR_ACCOUNT_PASSWORD',
'file': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
}
response = requests.post(url, data=payload, timeout=30)
response.raise_for_status()
result = response.json()
if result.get('success') is False:
raise RuntimeError('API error: %s' % result.get('msg'))
print(result)
const url = 'https://api.replier.net/UploadFile';
const payload = new URLSearchParams({
mobile: '447700900123',
password: 'YOUR_ACCOUNT_PASSWORD',
file: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
});
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: payload,
});
const result = await response.json();
if (result.success === false) {
throw new Error(`API error: ${result.msg.join(', ')}`);
}
console.log(result);
const axios = require('axios');
const payload = new URLSearchParams({
mobile: '447700900123',
password: 'YOUR_ACCOUNT_PASSWORD',
file: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
});
(async () => {
try {
const { data } = await axios.post('https://api.replier.net/UploadFile', payload, { timeout: 30000 });
if (data.success === false) {
throw new Error(`API error: ${data.msg.join(', ')}`);
}
console.log(data);
} catch (err) {
console.error(err.message);
}
})();
$.ajax({
url: 'https://api.replier.net/UploadFile',
method: 'POST',
data: {
mobile: '447700900123',
password: 'YOUR_ACCOUNT_PASSWORD',
file: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
},
dataType: 'json',
})
.done(function (result) {
if (result.success === false) {
console.error('API error: ' + result.msg.join(', '));
return;
}
console.log(result);
})
.fail(function (xhr) {
console.error(xhr.status, xhr.responseText);
});
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
var payload = new Dictionary<string, string>
{
{ "mobile", "447700900123" },
{ "password", "YOUR_ACCOUNT_PASSWORD" },
{ "file", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." },
};
var response = await client.PostAsync("https://api.replier.net/UploadFile", new FormUrlEncodedContent(payload));
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}
import java.io.IOException;
import okhttp3.*;
public class Example {
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
FormBody.Builder form = new FormBody.Builder();
form.add("mobile", "447700900123");
form.add("password", "YOUR_ACCOUNT_PASSWORD");
form.add("file", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...");
Request request = new Request.Builder()
.url("https://api.replier.net/UploadFile")
.post(form.build())
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println(response.body().string());
}
}
}
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://api.replier.net/UploadFile')
response = Net::HTTP.post_form(uri, {
'mobile' => '447700900123',
'password' => 'YOUR_ACCOUNT_PASSWORD',
'file' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...',
})
result = JSON.parse(response.body)
raise "API error: #{result['msg'].join(', ')}" if result['success'] == false
puts result
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"strings"
)
func main() {
form := url.Values{}
form.Set("mobile", "447700900123")
form.Set("password", "YOUR_ACCOUNT_PASSWORD")
form.Set("file", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...")
resp, err := http.Post(
"https://api.replier.net/UploadFile",
"application/x-www-form-urlencoded",
strings.NewReader(form.Encode()),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}
Samples use POST with a form-encoded body so credentials stay out of the URL. The API reads JSON bodies, form bodies and query strings alike.
Response
On failure, every endpoint answers with HTTP 200 and this envelope, where the string is a code from the error reference:
{
"success": false,
"msg": ["0008"]
}