• 18-03-2025, 15:54:53
    #1
    Merhabalar elimde bir xenforo sitesi mevcut api anahtar oluşturdum ve aşağıdaki bilgiler ile post gönderiyorum.
    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;
  • 18-03-2025, 18:11:03
    #2
    Kendisi son derece ilgili ve başarılı , Tebrik ederim hocam uzun süre birlikte çalışmak dileği ile