是否有一种方法(或工具)可以帮助查看(或记录)HTML <FORM METHOD=POST>中响应单击<INPUT TYPE="submit">按钮的确切内容?
有办法吗?
curl -X POST -H "Content-Type:application/xml" --data @myfile.xml http://example.com
Run Code Online (Sandbox Code Playgroud)
但直接在PHP?
CURLOPT_PUT/ CURLOPT_UPLOAD以及file_get_contents以及exec
不是解决方案,因为它必须是POST,文件很大,所以必须流式传输.
有任何想法吗?
我建立一个应用程序,我得到一个NetworkOnMainThreadException INSIDE的的AsyncTask
呼叫:
new POST(this).execute("");
Run Code Online (Sandbox Code Playgroud)
的AsyncTask:
public class POST extends AsyncTask<String, Integer, HttpResponse>{
private MainActivity form;
public POST(MainActivity form){
this.form = form;
}
@Override
protected HttpResponse doInBackground(String... params) {
try {
HttpPost httppost = new HttpPost("http://diarwe.com:8080/account/login");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("email",((EditText)form.findViewById(R.id.in_email)).getText().toString()));
//add more...
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
return new DefaultHttpClient().execute(httppost);
} catch (Exception e) {
Log.e("BackgroundError", e.toString());
}
return null;
}
@Override
protected void onPostExecute(HttpResponse result) {
super.onPostExecute(result);
try {
Gson gSon = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
gSon.fromJson(IOUtils.toString(result.getEntity().getContent()), LogonInfo.class).fill(form);
} catch …Run Code Online (Sandbox Code Playgroud) 我有一个运行良好的curl命令,但我需要在ruby脚本中自动执行此操作,
卷曲cmd:
curl -u usrname:pwd -X POST --data "del=false&val=100" http://localhost:1111/sample/path
Run Code Online (Sandbox Code Playgroud)
我写了以下代码:
uri = URI::HTTPS.build(:host => "localhost", :port => 1111)
uri.path = URI.escape("/sample/path")
client = Net::HTTP.new("localhost", "1111")
req = Net::HTTP::Post.new(uri.request_uri, {"User-Agent" => "UA"})
req.set_form_data({"del" => "false", "val" => "100"})
req.basic_auth("usrname", "pwd")
res = client.request(req)
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,我有一个编码的URL我传递给URI.escape,这让我发布了关于错误响应的问题.Foud问题并修复它:)
我正在尝试设置Django API(POST API端点).我希望有相同的URL路径指向同一个处理不同的函数,因为它是POST或GET.因此,我使用了这样的方法
def handle_post(request):
dict = {}
dict['email'] = "test"
if request.method == "POST":
return HttpResponse(json.dumps(dict), content_type="application/json")
Run Code Online (Sandbox Code Playgroud)
在url.py中,我有以下代码
router = routers.DefaultRouter()
router.register(r'notes', UsernotesViewSet)
urlpatterns = patterns('',
url(r'^', include(router.urls)),
url(r'^admin/', include(admin_site.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^docs/', include('rest_framework_swagger.urls')),
url(r'^example/postrequest', handle_post),
)
Run Code Online (Sandbox Code Playgroud)
但是当我在URL http://127.0.0.1:8000/example/postrequest?requestid=abc&starthour=10上执行POST时,我无法完成这项工作 .我没有发布任何内容,只是在httpclient上将方法从GET更改为POST以尝试此API.如果我没有将任何内容发布到URL,这样可以吗?
我收到403错误,如下所示:
禁止(403)
CSRF验证失败.请求中止.
您看到此消息是因为此站点在提交表单时需要CSRF cookie.出于安全原因,需要此cookie,以确保您的浏览器不会被第三方劫持.如果您已将浏览器配置为禁用cookie,请重新启用它们,至少对于此站点或"同源"请求.
感谢任何帮助.
我在PHP中有以下代码片段:
if (strcasecmp($_POST['method'], 'assignId') == 0) {
$username = $_POST['username'];
$response['code'] = 1;
$response['status'] = $api_response_code[$response['code']]['HTTP Response'];
$sql = "CALL new_person('$username')";
if (($result = $conn->query($sql)) === TRUE) {
$row = $result->fetch_assoc();
$response['data'] = $row;
}
deliver_response($response);
Run Code Online (Sandbox Code Playgroud)
new_person是一个存储过程,它返回一个id,它已经过测试,可以正常工作并deliver_response返回输入的JSON格式。它也已经过测试,可以正常工作。
为什么POST请求返回404错误?
存储过程正在执行,但不会返回结果。最后,当我将POST方法更改为GET并发出get请求时,它可以正常工作!
我正在写laravel中的第一个应用程序,这对于新的laravel开发人员来说是非常好的环境.缩短故事:我通过php artisan命令创建了两个雄辩的模型,并以相同的方式创建了相应的控制器.其中之一是类控制器的内部"成员"的模式,我创建的公共职能,但是当我尝试发布到应该使用存储路线()函数航线实际使用index()函数.
控制器:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Member;
use Response;
class MemberController extends Controller
{
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$members = Member::all();
return Response::json([
'data' => $this->transformCollection($members)
], 200);
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
//
}
/**
* @param Request $request
* @return mixed
*/
public function store(Request $request) …Run Code Online (Sandbox Code Playgroud) 我能够成功地对其他Walmart API端点进行API调用(特别是GET请求端点),但是批量项端点(POST请求)会导致错误,即使我似乎一切都正确.
以下是对该端点的引用 https://developer.walmartapis.com/#bulk-createupdate-items
HTTP响应META信息
500内部服务器错误
XML
HTTP响应
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:errors xmlns:ns2="http://walmart.com/">
<ns2:error>
<ns2:code>SYSTEM_ERROR.GMP_GATEWAY_API</ns2:code>
<ns2:description>Couldn't determine the boundary from the message!</ns2:description>
<ns2:info>System encountered some internal error.</ns2:info>
<ns2:severity>ERROR</ns2:severity>
<ns2:category>DATA</ns2:category>
<ns2:causes/>
<ns2:errorIdentifiers/>
</ns2:error>
</ns2:errors>
Run Code Online (Sandbox Code Playgroud)
HTTP请求:
url https://marketplace.walmartapis.com/v2/feeds?feedType=item
方法 POST
请求标头
WM_SVC.NAME: Walmart Marketplace
WM_CONSUMER.ID: {my consumer id key}
WM_QOS.CORRELATION_ID: {my arbitrary text key}
Content-Type: multipart/form-data
Accept: application/xml
WM_SEC.AUTH_SIGNATURE:{my jar-file-generated key}
WM_SEC.TIMESTAMP:{my jar-file-generated timestamp}
Run Code Online (Sandbox Code Playgroud)
POST有效负载(只是文本,参数没有键)
<?xml version="1.0" encoding="UTF-8"?>
<MPItemFeed xmlns="http://walmart.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://walmart.com/ MPItem.xsd ">
<MPItemFeedHeader>
<version>2.1</version>
<requestId>qqq</requestId>
<requestBatchId>qqq1</requestBatchId>
</MPItemFeedHeader>
<MPItem>
<sku>qqq</sku> …Run Code Online (Sandbox Code Playgroud) 有没有一种方法可以使用nginx通过http将文件上传到服务器?
我有一个程序,该程序基本上使用curl和通过HTTP的POST方法将文件发送到完全不同的企业软件。我们希望复制类似的内容,但遇到障碍。
我已经安装了nginx并进行了基本配置,我希望能够上传/ data / files / incoming下的文件
server {
listen testserv1;
location /upload/ {
limit_except POST PUT { deny all; }
client_body_temp_path /data/files/incoming/;
client_body_in_file_only on;
client_body_buffer_size 128k;
client_max_body_size 100M;
proxy_pass_request_headers on;
proxy_set_body $request_body_file;
proxy_pass http://127.0.0.1/upload;
proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)
我基本上在nginx.conf上保留了常规配置,并添加了上面的内容。所以我的问题是,我怎么知道实际上在工作?我在另一台服务器上尝试运行程序,该程序据说可以发布文件,但什么也没有。有没有办法从另一个系统测试此配置?我在配置上缺少什么吗?
任何帮助,任何事情都将不胜感激。
链接到项目 - > https://github.com/crumdev/hqbbq.git
我有一个简单的3页MVC网站,有1个控制器.对于联系页面,我有一个小的3输入表单.以下是Controller方法:
[Route("contact/")]
public IActionResult Contact()
{
return View();
}
[HttpPost]
public IActionResult Contact(string name, string email, string message)
{
ViewBag.Name = name;
ViewBag.Email = email;
ViewBag.Message = message;
return View();
}
Run Code Online (Sandbox Code Playgroud)
当我在HttpPost的Contact方法中提交带有断点的表单时,它永远不会中断,而是使用常规方法并再次返回视图.我已经尝试将我的表单简化为name字段,只捕获它并且它不会进入POST方法.我给了常规的Contact方法[HttpGet]属性,所以它只能严格用于GET请求,当我提交表单时,它会完全绕过我的控制器并返回除了"Hello World!"之外的空白的异常页面.屏幕上.我已经阅读了文档,并在teamtreehouse.com上阅读了常规ASP.Net的教程,但是无法理解为什么它会以这种方式运行.
编辑:这是提交POST的页面的代码.我只是使用一个纯HTML表单和POST方法来提交数据.
https://github.com/crumdev/hqbbq/blob/master/HQ-BBQ/Views/Home/contact.cshtml