【问题标题】:POST becomes GET on outgoing trafficePOST 在传出流量上变为 GET
【发布时间】:2016-02-16 17:32:45
【问题描述】:

我在 Google Cloud 虚拟机上有一个 Web 实例,构建为 UBUNTU

我正在尝试将数据发布到外部 API,但是当我观察流量时,POST 显然变成了 GET。

我检查了服务器 .htaccess 和 site.conf 文件,没有发现任何重写或限制的迹象

我已经尝试过 PHP CURL 和 JQUery。以下是每次尝试的重要代码 sn-ps

curl_setopt($ch, CURLOPT_POST, 1); // I have also tried TRUE
curl_setopt($ch, CURLOPT_POSTFIELDS,"\$xmldata=".urlencode($xmldata));
ob_start();

和Jquery方法(完整)

<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>


<script type="application/javascript">
    $(function () {
        var example = {
            "Title": "REST DN transaction (JSON)",
            "Description": "REST DN transaction (JSON)",
            "TransactionType": 0,
            "Partner": {
                "PartnerId": xxxx },
            "Buyer": {
                "Email": "xxxx@hotmail.com", "Initiator": false,
                "CompanyChk": false,
                "AutoAgree": false, "AgreementChecked": false
            }, "Seller": {
                "Email": "xxxx@hotmail.com", "Initiator": true,
                "CompanyChk": false,
                "AutoAgree": false, "AgreementChecked": false
            }, "LineItems": [
                {
                    "ItemName": "test.com", "Description": "DN description", "Quantity": 1,
                    "Price": 2000,
                    "Accept": true,
                    "SellComm": 9.1,
                    "BuyComm": 10.1,
                }],
            "EPayment": 0, 
            "ShipmentFee": 0, 
            "ShipmentPayment":0, 
            "DomainNameType": 0, 
            "InspectionLength": 6, 
            "Currency": "USD", 
            "Fulfillment": 2, 
            "CommissionType": 1, 
            "InitiationDate": "2014-04-15", 
            "TermsLocked": true, 
            "AllowReject": true
        };

        $.post({
            type: "POST",
            method: "POST",
            dataType: 'jsonp',
            data :JSON.stringify(example),
            url: "https://thedomain.com/api/Transaction",
            contentType: "application/json"
        });
    });
</script>

我也试过 $.ajax(

域名是占位符

谁能告诉我为什么在谷歌开发者控制台中,当我观看时间线时,传出请求总是一个 GET

API 还返回一条消息,指示 GET 是不允许的

【问题讨论】:

  • 澄清一下,发送的数据没有错误,我只是在这两种情况下都没有将它添加到sn-p
  • 如果您不向我们展示更多代码,我们将无法告诉您错误是什么...... curl 不只是为了自娱自乐地将 POST 切换为 GET!
  • 你说得对!!但它是!!我将添加其余代码
  • 我已经完整地添加了 JQuery 版本.. 什么都没有,我运行这个脚本并观察控制台,它在每个阶段都显示为 GET..,任何时候都不是 POST 方法.. 除非我读错了谷歌开发控制台

标签: json post curl get


【解决方案1】:

问题不在于代码(毫不奇怪),而在于 API。感谢那些花时间回复的人

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 2012-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-13
    • 2021-10-13
    • 1970-01-01
    相关资源
    最近更新 更多