问题是我无法使用 Postman 应用程序执行 PUT 或 POST。但删除是可能的。是的,我为公共用户启用了所有操作。
这是 GET 请求结果:
{
"data": [
{
"id": 2,
"attributes": {
"title": "23123",
"game": "1231",
"players": "2312313",
"createdAt": "2022-02-19T16:36:34.221Z",
"updatedAt": "2022-02-19T16:36:34.971Z"
}
}
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 1
}
}
}
Run Code Online (Sandbox Code Playgroud)
最后请求 POST 后结果如下:
{
"data": null,
"error": {
"status": 400,
"name": "ValidationError",
"message": "Missing \"data\" payload in the request body",
"details": {}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是什么?
我使用Ajax(jQuery)和POST方法来更新数据库中的数据.我做以下事情:
我不知道如何验证用户是否从我的网站发送数据而不是从其他地方发送数据.请帮我解决这个问题.谢谢 !
如果我的表单中有一些隐藏的输入:
<input type="hidden" name="test" value="somedata">
<input type="hidden" name="entry0" value="moredata">
<input type="hidden" name="entry1" value="moredata">
<input type="hidden" name="entry2" value="moredata">
<input type="hidden" name="entry3" value="moredata">
<input type="hidden" name="entry4" value="moredata">
Run Code Online (Sandbox Code Playgroud)
现在,一旦提交表单并且我从帖子中获取数据,如果我尝试调用,$_POST['test']那么我将获得"somedata"值.但如果我这样做:
for($i = 0; $i < 5; $i++)
{
$x = 'entry{$i}';
echo $_POST[$x]; // This does not work.
}
Run Code Online (Sandbox Code Playgroud)
然后,我没有为每个"条目"输入返回"更多数据"值.如果我打印出定义为的字符串$x,那么我会得到我之后的字符串,但它似乎不想像这样工作$_POST.任何人有任何想法我怎么能解决这个问题?
谢谢
我正在为我的Android手机构建一个小应用程序,使用非常基本的REST界面将文本消息转发到Web服务器.
我正在使用android 4.0.3 SDK.我使用Django和Django restframework包在python中开发了webservice.设置完全开箱即用.基本上有一个端点接收包含消息信息(发送者,正文,日期)的JSON对象的POST.我使用cURL使用以下命令测试了该服务:
curl -X POST -H 'Content-Type: application/json' --data '{"sender":"+xxxxxxxx", "body": "test", "send_date":"2011-03-20 16:32:02"}' http://[...]/messages.json
一切正常,我得到了预期的响应:
{"body": "test", "send_date": "2011-03-20T16:32:02", "id": 25, "sender": "+xxxxxxxxxx"}
现在我设置了Android应用程序.它是一个简单的BroadcastReceiver子类,包含一个私有的AsyncTask类:
private class httpPost extends AsyncTask<String, Void, JSONObject> {
protected JSONObject doInBackground(String... args) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpParams myParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(myParams, 10000);
HttpConnectionParams.setSoTimeout(myParams, 10000);
String url = args[0];
String json=args[1];
JSONObject JSONResponse = null;
InputStream contentStream = null;
String resultString = …Run Code Online (Sandbox Code Playgroud) 我无法让Apache HttpClient正确发送HttpPost标头.
我没有问题发送名称值对和诸如此类的东西,但每当我设置或添加POST标题时,它会在请求发生时消失.
我已经尝试了setHeader和addHeader,以及同时尝试这两个.
这是我的代码:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://posttestserver.com/post.php");
httppost.setHeader("Authorization: Bearer", accessToken);
httppost.addHeader("Authorization: Bearer", accessToken);
Log.d("DEBUG", "HEADERS: " + httppost.getFirstHeader("Authorization: Bearer"));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httppost, responseHandler);
Log.d("DEBUG", "RESPONSE: " + responseBody);
Run Code Online (Sandbox Code Playgroud)
此外,执行请求之前的调试语句打印出正确的标头,因此我知道它正在添加,然后稍后删除.
任何帮助将非常感激!
编辑:如果重要的话,这都在AsyncTask中运行.我认为没有,因为有一个NetworkOnMainThread异常抛出,但我认为值得一提.
以下代码片成功发送POST请求但不在$ sendStream中发送数据的问题(流是有效的并包含数据 - 已经过验证):
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-type: application/x-rethync-request'));
curl_setopt($request, CURLOPT_HEADER, true);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_INFILE, $sendStream);
curl_setopt($request, CURLOPT_INFILESIZE, stream_length($sendStream));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
$response = curl_exec($request);
Run Code Online (Sandbox Code Playgroud)
我在这里阅读了所有与cURL POST相关的帖子,但没有运气.为什么没有发布数据?
我正在尝试使用Google 在此处描述的刷新令牌来获取新的访问令牌.Google说我需要发出HTTP请求.我不知道怎么做,所以我从这里查看了如何做到这一点.但是,我必须正确地发布帖子,因为我收到invalid_request错误.
以下是我的相关代码:
h = Http()
post_data = {'POST': '/o/oauth2/token HTTP/1.1',
'HOST:': 'accounts.google.com',
'Content-Type:': 'application/x-www-form-urlencoded',
'client_id':ClientID,
'client_secret':ClientSecret,
'refresh_token':SavedRefreshToken,
'grant_type':'refresh_token'}
resp, content = h.request("https://accounts.google.com/o/oauth2/token",
"POST",
urlencode(post_data))
Run Code Online (Sandbox Code Playgroud)
我得到的回应是:
{
"error" : "invalid_request"
}
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我正在向ADFS发送saml 2.0注销请求并获取注销响应,状态代码为:"urn:oasis:names:tc:SAML:2.0:status:Requester".
我检查了Name ID值,它等于Assertion上的名称ID.我没有看到ADFS日志有任何错误.
这是我的退出请求:
<?xml version="1.0"?>
<samlp:LogoutRequest xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0" Destination="https://IDP_adfs.xxx.com/adfs/ls/" ID="id007471cfceb449239be1a6a48d28ae89" IssueInstant="2015-01-05T15:30:56.3978094Z">
<saml:Issuer>https://SP.xxx.com</saml:Issuer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#id007471cfceb449239be1a6a48d28ae89">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>GsF...t/uwM=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>qY5RIT/eT9Tgkg7dj...IPn/2STu7iepIQ==</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>MIIC5jCCAc...qAdOYsuKUgO9WNers=</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
<saml:NameID Format="http://schemas.xmlsoap.org/claims/UPN">user@xxx.com</saml:NameID>
<samlp:SessionIndex>_48b8991b-d3c4-4f8a-9c8b-a86e0a718c95</samlp:SessionIndex>
</samlp:LogoutRequest>
Run Code Online (Sandbox Code Playgroud)
这是我的退出响应:
<?xml version="1.0"?>
<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_79573c99-c8d3-4ea3-8b53-e15551128318" Version="2.0" IssueInstant="2015-01-05T15:31:02.954Z" Destination="https://SP.xxx.com/Account/logout/" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="id007471cfceb449239be1a6a48d28ae89">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://IDP_Adfs.xxx.com/adfs/services/trust</Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#_79573c99-c8d3-4ea3-8b53-e15551128318">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>B/badvPpTrEuKZsqOvBQM54CIJ8=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>cWIEl5wY3...lIiQDltacRcjxyw==</ds:SignatureValue> …Run Code Online (Sandbox Code Playgroud) 这是我的功能
不知道问题出在哪里
fetchData() {
fetch(REQUEST_URL, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
Request : 'menu',
active : '1',
})
}).then((response) => response.json())
.then((responseData) => {
this.setState({
menu: responseData.Response,
});
})
.catch((error) => {
console.warn('error',error);
})
.done();
}
Run Code Online (Sandbox Code Playgroud)
请指出功能上的问题
嗨,我正在使用post and get响应方法,它工作良好,但是有两个问题:1-当响应为get时,我无法使用警报; 2-在另一个变化的响应中,我无法获得api_token和Id
这是我用于发布的代码**我使用的是本地代码,但是您可以更改网址并对此进行测试**
var request = URLRequest(url: URL(string: "http://172.16.15.137:8888/TheoryTipo/public/api/register")!)
request.httpMethod = "POST"
let postString = "name=\(usernameforsignup.text!)&email=\(emailforsignup.text!)&password=\(passwordforsignup.text!)&tel=\(phonenumberforsignup.text!)"
print(postString)
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else {
// check for fundamental networking error
print("error=\(error)")
let alertController = UIAlertController(title: "Error", message: "can't Connect to the server", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction(title: "retry", style: UIAlertActionStyle.default)
{
(result : UIAlertAction) -> Void in
}
alertController.addAction(okAction)
self.present(alertController, …Run Code Online (Sandbox Code Playgroud)