如何解决如何解决502 Bad Gateway错误
我有
curl --include --request POST --header "Content-Type: application/x-www-form-urlencoded" --data-binary "username=xx@xxtemple.net&password=XXXXXXXX" 'https://api.xxsuccess.com/v1/auth'
运行时没有任何错误,然后执行我想要的操作。
当我在 SAME计算机上运行以下C#代码时,我收到502 Bad Gateway Error:
string requestUri = "https://api.xxsuccess.com";
var client = new RestClient(requestUri);
client.Authenticator = new RestSharp.Authenticators.HttpBasicAuthenticator("xx@xxtemple.net","XXXXX");
var request = new RestRequest("v1/auth",Method.POST);
IRestResponse restResponse = client.Execute(request);
任何想法如何解决问题? 为什么“ Curl”有效,而代码无效?
解决方法
macro_rules! deref_impl {
($($sig:tt)+) => {
impl $($sig)+ {
fn bar(&self) {
(**self).bar()
}
}
};
}
deref_impl!(<'a,N> Foo for &'a N where N: Foo + ?Sized);
deref_impl!(<'a,N> Foo for &'a mut N where N: Foo + ?Sized);
deref_impl!(<N> Foo for Box<N> where N: Foo + ?Sized);
deref_impl!(<N> Foo for std::rc::Rc<N> where N: Foo + ?Sized);
deref_impl!(<N> Foo for std::sync::Arc<N> where N: Foo + ?Sized);
确实将数据(在本例中为您的用户名和密码)发布到请求正文中。 HttpBasic身份验证将您的身份验证信息放入#include <iostream>
#include <fstream>
#include <functional>
using namespace std;
void test_func()
{
int a[] = {20,42,41,40};
int b[] = {2,4,2,1};
cout << "Below is the result: "<< endl;
for (int i=0; i<4; i++){
cout << "***********************" << endl;
cout << a[i] << " : " << b[i] <<endl;
cout << "-----------------------" << endl;
}
}
void write_to_file(function<void()>test_func)
{
ofstream ofile;
ofile.open("abc.txt");
ofile << test_func(); // This is not allowed
ofile.close();
}
int main()
{
write_to_file(test_func);
return 0;
}
标头中。所以这些是不同的请求。
如果第一个请求有效,则还需要将数据放入主体以用于RestSharp请求
--data-binary
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。