c# - 通过c#将数据推送到gmail Streak
问题描述
我正在尝试通过 c# 中的 API 将数据推送到 gmail streak,基本上我正在尝试通过 API 创建管道,但它给出了 400 Bad Request 错误但我正在根据其网站链接中给出的所有数据传递所有数据:- https ://streak.readme.io/reference#create-a-pipeline
代码 -
try
{
CookieContainer myContainerpush = new CookieContainer();
HttpWebRequest requestpush = (HttpWebRequest)WebRequest.Create("https://www.streak.com/api/v1/pipelines/");
requestpush.Method = "POST";
requestpush.Credentials = new NetworkCredential("gh0b9shff5f77e310cea", "");
String encodedAllPipelines = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes("ee3deb0b9f7c4d6c92f5f5f77e310cea:"));
requestpush.Headers.Add("Authorization", "Basic " + encodedAllPipelines);
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// allows for validation of SSL conversations
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
requestpush.CookieContainer = myContainerpush;
requestpush.PreAuthenticate = true;
string postData = "{ name:'Hiring', teamWide: false,fieldNames: ['Test'],fieldTypes: ['TEXT_INPUT'],stageNames: ['SNOw'],teamkey: 'agxdsfsdfsdf9nYWVyEQsSBFRlYW0YgICI_fG-9QsM'}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
requestpush.ContentType = "application/x-www-form-urlencoded";
requestpush.ContentLength = byteArray.Length;
//// Get the request stream.
Stream dataStream = requestpush.GetRequestStream();
//// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
//// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = requestpush.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
// The using block ensures the stream is automatically closed.
using (dataStream = response.GetResponseStream())
{
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
}
// Close the response.
response.Close();
}
catch (Exception e)
{
e.Message.ToString();
}
解决方案
推荐阅读
- css - 具有非标准“正常”行高的字体
- php - 使用 hasMany 关系进行雄辩的急切加载不起作用
- jquery - jQuery 点击事件不适用于移动设备上的 SVG 元素
- mongodb - 在 MongoDB 集合中重命名数组中的属性
- netsuite - 迁移到 NetSuite SDF SuiteApp
- c# - UWP 将 MainView 替换为全屏框架
- mysql - 如何连接到 mysql 并在 Jenkins 自由式作业中传递凭据
- java - 如何在我初始化扩展片段时停止调用父片段的onActivityCreated?
- react-native - 在本机反应中运行后台任务的最佳方法是什么?
- xamarin.forms - 如何在 Xamarin.iOS 设计器中更改 xib 的大小?