我在Google Cloud虚拟机上有一个Web实例,构建为UBUNTU
我正在尝试将数据发布到外部API,但是当我观察流量时,POST显然变成了GET。
我检查了服务器.htaccess和site.conf文件,看不到重写或限制的错误
我已经尝试过PHP CURL和JQUery。以下是每次尝试的重要代码片段
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(
域名是占位符
任何人都可以在google开发者控制台中告知为什么我在观看时间表时传出请求始终是GET
API也会返回一个混乱,表明GET不允许
答案 0 :(得分:0)
问题不是代码(没有惊喜),而是API。感谢那些花时间回复的人