Laravel:在发布请求中发送JSON

时间:2020-05-16 22:05:53

标签: json laravel laravel-5

我正在发出一个发布请求,并使用以下原始数据在Postman中对其进行了测试:

{
    "fields":{
        "summary":"Testing",
        "issuetype":{
            "id":"10039",
            "type":"Task"
        },
        "project":{
            "key":"AG",
            "id":"10019"
        },
        "description":{
            "type":"doc",
            "version":1,
            "content":[
                {
                    "type":"paragraph",
                    "content":[
                        {
                            "text":"This is the description.",
                            "type":"text"
                        }
                    ]
                }
            ]
        }

    }
}       

我不确定如何格式化此数据以在Laravel中作为Post请求发送,因为我不能只使用相同的JSON格式 。

  $response = Http::withHeaders([
        'X-First' => 'foo',
        'X-Second' => 'bar'
    ])->post('https://atlassian.jira.com/rest/api/3/issue', [
        //data
    ]);

0 个答案:

没有答案