使用C#、.Net 4、5、RestSharp v4.0.3
尝试在GoCardless中创建api_key
我创建一个RestClient,如下所示:
var client = new RestClient();
client.BaseUrl = SandboxBaseUrl;
client.Authenticator = new HttpBasicAuthenticator(apiKeyId, apiKey);
client.AddDefaultHeader("GoCardless-Version", Properties.Settings.Default.GoCardlessVersion);
client.AddDefaultHeader("Accept", "application/json");
client.AddDefaultHeader("content-type", "application/json");
request.AddHeader("content-type", "application/json");当我在GoCardless上发帖时,我收到以下错误
{"error":{"message":"'Content-Type' header must be application/json or application/vnd.api+json ......发布于 2015-02-27 20:54:00
经过大量无果的搜索后,我放弃了,并在以前的StackOverflow帖子中使用了这些解决方案。比如
// Create the Json for the new object
StringBuilder requestJson = new StringBuilder();
var requestObject = new { api_keys = new { name = name, links = new { role = role } } };
(new JavaScriptSerializer()).Serialize(requestObject, requestJson);
...
// Set up the RestSharp request
request.Parameters.Clear();
request.AddParameter("application/json", requestJson, ParameterType.RequestBody);我明白为什么这样做了--甚至RestSharp这样做的意图也明白了。
https://stackoverflow.com/questions/28724283
复制相似问题