0

Is there up-to-date API documentation for devrant? I am stuck on the posting API calls, especially on what data is required.

Comments
  • 1
  • 1
    @C0D4 so I have been using that. However, the posting rants seem to be broken. Even using the built in console. I am unable to post rants via the API.
  • 1
    You got example code?
  • 0
    @C0D4 I am writing an API for C#

    ```

    string url = $"devrant/rants?app=3&rant={rant}&type={type}" +

    $"&token_id={DevrantAuth.AuthData.Id}&token_key={DevrantAuth.AuthData.Key}&user_id={DevrantAuth.AuthData.UserId}";

    return _httpClient.Post<PostRantResponse>(url) ?? new PostRantResponse();

    ```
  • 1
    The {rant} is url encoded ?

    And are you setting the content type in the headers?

    'Content-Type': 'application/x-form-urlencoded'
  • 0
    @C0D4 Yeah

    This is the response I get from the API,

    {"success":false,"error":"Invalid app id specified."}
  • 0
    @C0D4 So i have the following atm,

    public T? PostXForm<T>(string url, HttpContent content)

    {

    content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");

    HttpResponseMessage result = _httpClient.PostAsync(url,null).Result;

    return JsonConvert.DeserializeObject<T>(result.Content.ReadAsStringAsync().Result);

    }

    and

    HttpContent content = new FormUrlEncodedContent(

    new List<KeyValuePair<string, string>> {

    new("app", "3"),

    new("rant", HttpUtility.UrlEncode(rant)),

    new("type", type.ToString()),

    new("token_id", DevrantAuth.AuthData.Id.ToString()),

    new("token_key", DevrantAuth.AuthData.Key),

    new("user_id", DevrantAuth.AuthData.UserId.ToString())

    }

    );

    return _httpClient.PostXForm<PostRantResponse>("devrant/rants", content) ?? new PostRantResponse();

    But still no go
  • 0
Add Comment