Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

blixary's avatar

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?

0 likes
10 replies
martinbean's avatar

@blixary We have no idea what’s wrong either unless you tell us the error message you’re getting 🙂

blixary's avatar

@martinbean As mentioned, it's an api-specific error. Here the body:

"{"objects":null,"error":{"message":"Contact: set correct number abort","code":null,"data":null,"exceptionUUID":"cb221bb9-xxxx-xxxx-xxxx-05f39413da78"}}"

I also got this error in Postman until I added the category array with Id and ObjectName.

Snapey's avatar

@blixary so you are not sending the right request. Other than that, it's impossible to guess

martinbean's avatar

@blixary Why are deliberately being scant with details? How are we meant to help you when we have to drag details out of you?

If you want help, share details and stop being so resistant. People ask for details so they can understand what you’ve tried, what result you’re getting and what result your expecting to better diagnose; not because they are l33t haxx0rs trying to pwn your PC.

As mentioned, it's an api-specific error

Was I supposed to guess the error before I dragged it out of you? 🤷‍♂️

martinbean's avatar
Level 80

@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.

1 like
blixary's avatar

@martinbean Hi, I see that I have been very sparing with the details that might have provided clarity here. That wasn't really my intention, but I thought it might just be a syntax error that would be so easy to fix. In the end, and I appreciate this, you found the associated API and the solution there anyway based on the error message.

I tried your code and it works like that. Thank you a lot again.

Please or to participate in this conversation.