Thursday, May 3, 2018

Laravel POST request to API answer - development

Laravel POST request to API answer

I have got a Laravel Application which schould send a POST request with parameters to de WebUntis API and the response should be a sessionid. I can send a POST request and I get a answer but I do not get the sesseion key. I have tested the code in Postman and there it works.

route/api.php

Route::get('auth', 'UntisController@auth');

UntisController.php

class UntisController extends Controller
{

public function auth()
{

    $client = new GuzzleHttpClient();
    $req = $client->post( 'https://asopo.webuntis.com/WebUntis/jsonrpc.do?school=htblva_villach',[

                "id" => 8294829,
                "method" => "authenticate",
                "params" => [
                    "user" => "USERNAME",
                    "password" => "PASSWORD",
                    "client" => "web"
                ],
                "jsonrpc" => "2.0"
    ],
    ['Content-Type' => 'application/json'
    ]);



    dd($req);
}
}

the response I get with POSTMAN, the respones i want



from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-post-request-to-api-answer/
via Lzo Media

No comments:

Post a Comment