@blixary We have no idea what’s wrong either unless you tell us the error message you’re getting 🙂
Creating an API-Request...
Hi all,
following problem: I'm trying to integrate a private Third-party API into my laravel app.
First, I've built the Request in Postman, which works (l. https://prnt.sc/vW4Z9JO9jc7q). When now, when I try to integrate it in Laravel Http Client (l. https://prnt.sc/M56n6HANSN0O), I get an API-specific error.
I have no idea, what I'm doing wrong here. Can you help me?
@blixary So, back on topic. In Postman you had a field called surename but in your Laravel code you call this surname (no “e”).
Also, try passing an actual associative array for the request body:
$url = 'https://my.sevdesk.de/api/v1/Contact';
$request = Http::withToken($token, null)->asForm()->acceptJson()->post($url, [
'surename' => 'Max',
'familyname' => 'Mustermann',
'category' => [
'id' => '3',
'objectName' => 'Category',
],
]);
Because the documentation for the devDesk API say parameters should be sent with the Content Type application/x-www-form-urlencoded, but the Laravel HTTP sends POST requests as JSON by default. So use the asForm method like I have done to send the request as an encoded form rather than JSON.
Please or to participate in this conversation.