【发布时间】:2014-05-23 12:16:23
【问题描述】:
我正在尝试在 C# 中为 Pushbullet API 重现此 Curl 调用。
curl https://api.pushbullet.com/v2/pushes \
-u <your_api_key_here>: \
-d device_iden="<your_device_iden_here>" \
-d type="note" \
-d title="Note title" \
-d body="note body" \
-X POST
这是我复制它的代码:
var response = default(IRestResponse);
var request = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json };
var client = new RestClient();
client.BaseUrl = "https://api.pushbullet.com/v2/";
request.Resource = "pushes";
var bodyInformation = string.Concat(" { \"", Config.Settings.PushbulletAPIKey,
"\": { \"type\":\"note\", \"title\":\"", title, "\", \"body\":\"", message, "\" } }");
request.AddBody(bodyInformation);
response = client.Execute(request);
当我发送它时,它会返回:
{"error": {"message": "authentication token is missing or invalid.", "type": "invalid_user"}}
API 页面供参考:
【问题讨论】:
-
我假设这是一个错字?
request.AddBody(bodtInformation); -
PushBullet API Auth?的可能重复
-
那是我修正的错字仍然不行。