site url : https://example.com/api/threads
Header
XF-Api-Key : api anahtarı
json content
{
"node_id": 5,
"title": "Test thread",
"message": "Test thread"
}Bu post isteğine karşılık aşağıdaki hatayı alıyorum. Bunu baya araştırdım ve birçok yerde aynı sorun yaşanmış çözenler ise bir türlü bilgi paylaşmamış.Response:
{
"errors": [
{
"code": "required_input_missing",
"message": "Gerekli giriş eksik: node_id, title, message",
"params": {
"missing": [
"node_id",
"title",
"message"
]
}
}
]
} Edit:
Konu tarafımca uzun uğraşlar sonucu çözülmüştür. Yardımı olması açısından çözümü aşağıya bırakıyorum.
Örnek Python Kodu
import requests
headers = {
'Content-type': 'application/x-www-form-urlencoded',
'XF-Api-Key': 'api_key'
}
# Gönderilecek veriler
post_data = {
'node_id': 5,
'title': 'Python Test Konu Başlığı',
'message': 'Test Konu İçeriği'
}
# example.com site adresinizi girin.
url = 'https://example.com/api/threads/'
response = requests.post(url, headers=headers, data=post_data)
print(response.text)Örnek PHP Kodu<?php
$headers = array(
'Content-type: application/x-www-form-urlencoded',
'XF-Api-Key: apikey'
);
$post = [
'node_id' => 5,
'title' => 'Test Konu Başlığı',
'message' => 'Test Konu İçeriği',
];
$post = http_build_query($post);
// example.com site adresinizi girin.
$url = 'https://example.com/api/threads/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
$json = curl_exec($ch);
curl_close($ch);
echo $json;