Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to post on my twitter wall using a API.but i got an error.

here is my code:

var client = new RestClient("https://platform.hootsuite.com/v1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "xxxxxxxx-xxxx-xxx-xxxx-xxxxxxxxx");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxx");
request.AddHeader("text", "Message Schedule");
request.AddHeader("socialProfileIds", "xxxxxxxx");
request.AddHeader("scheduledSendTime", "2018-07-27 17:30:00");
request.AddHeader("emailNotification", "false");
IRestResponse response = client.Execute(request);


What I have tried:

run code on postman app but getting same error. and not find any solution of it.. any one suggest me the solution.
Posted
Updated 30-Jul-18 7:02am

1 solution

You have no data attached to your request; you're loading everything as a header. That could easily result in the error that you're seeing.

Items that are meant to be part of the request payload, not the headers, should be added via:
C#
request.AddParameter("text", "Message Schedule");
request.AddParameter("socialProfileIds", "xxxxxxxx");
request.AddParameter("scheduledSendTime", "2018-07-27 17:30:00");
request.AddParameter("emailNotification", "false");


It also looks like the RestSharp API expects authentication to be handled differently, and that might be interfering with your testing.

Read the docs:

Home · restsharp/RestSharp Wiki · GitHub[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900