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

fatima1's avatar

API to store data of two models

hi all i have external API for loading data, i have job and file models (one to one relationship)

i want to create post method to store data from form to database if i use each model seperatly it work but when i put the two models in sam function it give this error


ServerException in RequestException.php line 113:
Server error: `POST http://aaaa.test/api/ime` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow" />
<style>
(truncated...)

here is my code

 $job = $request->job_id;
        $url = 'http://careers1.test/api/ime';
        $client = new Client();

        $guzzleResult = $client->post($url, [
            'form_params' => [
                'job_id'=>$job,
                'name'=>$request->name,
                'email'=>$request->email,
               
            ]
        ]);

        $job_req = json_decode($guzzleResult->getBody(),true);
        $id = $job_req['job_req']['req']['job_id'];

        $guzzleResult1 = $client->post($url, [
            'form_params' => [
                'jobReq_id'=>$id,
                'filename'=>'filename'

            ]
        ]);
0 likes
4 replies
fatima1's avatar

@MITHRANDIR -

2018-12-11 11:42:31] local.ERROR: exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `POST http://aaa.test/api/ime` resulted in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
    <head>
        <meta name="robots" content="noindex,nofollow" />
        <style>
             (truncated...)
' in /Applications/XAMPP/xamppfiles/htdocs/aaa/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Mithrandir's avatar

Are you debugging the requestING or the requestED service? Because it seems the Guzzle requests receive error 500's.

Please or to participate in this conversation.