我正在通过API向另一个服务发送HTTP Post请求以创建订单。问题是,它需要数组中的一些HTTP参数。
这些是我现在使用的参数:
"Content-Type: application/json",
"Accept: application/json",
"Stream-Nonce:".$randomstring2,
"Stream-Party:***************",
"Authorization: bearer ".$result_array["access_token"],
我需要补充一点:
"header": {
"orderNo": "ABCD123456",
"orderDate": "2018-07-23",
"requiredDate": "2018-07-31",
"partner": {},
"orderType": "DELIVERY",
"serviceLevel": "STANDARD",
"services": [],
"customer": {},
"customerOrderNo": "ABC1234567890",
"orderNotes": "These notes relate to the order",
"driverNotes": "These notes are for the driver",
"routeInfo": "CC05"
},
这是直接从我使用的服务留档。问题是标题:{...}。
我尝试使用不同的数组格式,如下所示:
'Content-Type' => ' application/json',
'Accept' => ' application/json',
'Stream-Nonce' => ''.$randomstring2,
'Stream-Party' => '***************',
'Authorization' => ' bearer '.$result_array['access_token'],
在这种情况下,我相信很容易进入...=
我能在这里做什么?谢谢
我读了go2streamdoc.this很容易,而使用guzzle.below就是例子。
如果你遇到一些问题,大多数可能是错误的帖子数据。
如果你有任何进一步的问题,请评论给我。
// composer require guzzlehttp/guzzle
$client = new \GuzzleHttp\Client();
$headers = [
// "Content-Type" => "application/json",
"Stream-Nonce" => $randomstring2,
"Stream-Party" => $streamParty,
"Authorization" => "bearer ".$result_array["access_token"],
];
$body = [
"header" => [
"orderNo" => "ABCD123456",
"orderDate" => "2018-07-23",
"requiredDate" => "2018-07-31",
"partner" => [],
"orderType" => "DELIVERY",
"serviceLevel" => "STANDARD",
"services" => [],
"customer" => [],
"customerOrderNo" => "ABC1234567890",
"orderNotes" => "These notes relate to the order",
"driverNotes" => "These notes are for the driver",
"routeInfo" => "CC05"
],
"collection" => [
"address" => [
"name" => "Proximity Resourcing Ltd",
"address1" => "6 Kerry Hill",
"address2" => "Off Town Street",
"address3" => "Horsforth",
"address4" => "Leeds",
"address5" => "West Yorkshire",
"country" => "GB",
"postcode" => "LS18 4AY",
"lat" => 53.837496,
"long" => -1.640644,
"nuts" => "UKE42",
"locationNotes" => "These notes relate to the location"
],
"contact" => [
"name" => "Jane Contact",
"tel1" => "0113 000 0000",
"tel2" => "0113 000 0000",
"mobile" => "07801 000000",
"fax" => "0113 000 0000",
"email" => "sales@go2stream.com"
],
"required" => [
"fromDateTime" => "2018-07-31T12 => 00 => 00Z",
"toDateTime" => "2018-08-01T17 => 00 => 00Z"
],
"collectionMethod" => "NORTH",
"timeOnSite" => [
"unload" => 60,
"assembly" => 30
],
"bookingRequired" => true,
"items" => [
[
"sequence" => 1,
"parentSequence" => 2,
"code" => "ABC123",
"description" => "Widget",
"quantity" => 10,
"weight" => 150,
"cube" => 3.5,
"assemblyTime" => 30,
"stockLocation" => "LEEDS",
"onHandDate" => "2017-07-30",
"packageId" => "ABCD1234567890",
"notes" => "Include product manual within packaging.",
"packageType" => "PALLET"
]
]
]
];
$response = $client->request('POST',"https => //www.demo.go2stream.net/api/orders/orders",[
'headers' => $headers,
'json' => $body,
]);
这是我想转换为数组的值。我知道这是一个很简单的问题,但是有人能帮我吗?
在…方面 在我的代码中,我试图放入一个我之前生成的随机数,但当applet启动时,当我按下按钮时,它会给我一个错误,我想把代码放入所有的按钮,因为我不想要重复的数字,我想要每个按钮随机生成的数字。我希望你能帮助我。 我得到的错误是线程“AWT-EventQueue-1”java.lang.IndexOutOfBoundsException:index:0,size:0中的异常
问题内容: 对于请求和JSON,我是一个菜鸟。在我的应用程序内部,我发送到服务器并取回东西,因此我可以使用它。我尝试查找不同的东西,但似乎并没有真正找到我想要的东西。所以我找回了似乎格式化为JSON的内容。我想知道如何将其放入NSMutable数组中。我获取此JSON的方法是使用AFNetworking的AFJSONRequestOperation。 我的回应看起来像这样。 问题答案: 如果您的J
问题内容: 我想从字节数组中提取一组坐标到DoubleBuffer中。 以下是如何将一组坐标从主字节数组提取到另一个字节数组的示例。 我的问题是: 如何将geomCoords字节数组放入DoubleBuffer? 还是 可以在不创建geomCoords的情况下将这些数据放入DoubleBuffer中?速度和效率是关键,因此任何捷径或优化都是最欢迎的! 问题答案: 如果您知道字节缓冲区中的8个字节确
如何在邮递员中传递此表单数据? 我试过这种方法,但不起作用
我有一个来自PHP的json POST URL“http://localhost:8080/demo/test” 我的webController 服务文件 myDAO文件 我怎样才能从URL到这个道上发布数据,我对Java是新的,提前感谢 更新 我发现了这个错误 HTTP错误405访问/backend/test时出现问题。原因:不支持请求方法“Get” 使用getter和setter新建类文件 新