So Im trying to set up RestSharp to use Moment Task scheduling according to the docs http://momentapp.com/docs
here is my code.
public class MomentApi : ITaskScheduler
{
const string BaseUrl = "https://momentapp.com";
private RestResponse Execute(RestRequest request)
{
var client = new RestClient();
client.BaseUrl = BaseUrl;
request.AddParameter("apikey", "MYAPIKEYHERE", ParameterType.UrlSegment); // used on every request
var response = client.Execute(request);
return response;
}
public HttpStatusCode ScheduleTask(DateTime date, Uri url, string httpMethod, Uri callback = null)
{
var request = new RestRequest(Method.POST);
request.Resource = "jobs.json";
request.AddParameter("job[uri]", "http://develop.myapp.com/Something");
request.AddParameter("job[at]", "2012-06-31T18:36:21");
request.AddParameter("job[method]", "GET");
var response = Execute(request);
return response.StatusCode;
}
The problem is that it is always returnig HTTP 422
please help.
So this is what I ended up with. found a sample here http://johnsheehan.me/blog/building-nugetlatest-in-two-hours-3/
Im not completely sure on when I should use AddParameter and when I should use AddUrlSegment but anyways it works now