samedi 16 mai 2020

Laravel: Sending JSON in post request

I am making a post request and tested it in Postman with the raw body data as:

{
    "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"
                        }
                    ]
                }
            ]
        }

    }
}       

I am not sure how to format this data to send as a Post request in Laravel though, since I can't just use the same JSON format .

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


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire