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

pllaguno's avatar

can't get store api call to work.

Whenever i try and call my store api call i get a 500 error. i have no idea if it is womething on the client side not sending correctly the json or something on my server side. I get this response back.

"{\"errorMessages\":[\"The remote server returned an error: (500) Internal Server Error.\"],\"errors\":{}}"

my controller method looks like the following, the dd(); is to see how the data is coming through. obiously the 500 error is when it is commented out.

public function store(Request $request)
    {
        //dD($request->all());
        $Pemex = Pemex::create($request->all());

        return response()->json($Pemex, 201);
    }

whenever i uncomment the DD(); i get the following info back:

array:1 [\n  0 => array:9 [\n    \"Economico\" => \"TLN-42\"\n    \"Latitude\" => 25.3958788\n    \"Longitud\" => -100.1214968\n    \"ActivityDateTime\" => \"2019-05-08T19:41:48\"\n    \"EventSubType\" => \"SMDP_EVENT_VEHICLE_MOVED_WITH_IGIOFF\"\n    \"Speed\" => 0\n    \"Company\" => \"Teletrac Navman\"\n    \"OwnerID\" => \"a387f15b-1769-482f-a5e4-c6829e1483a9\"\n    \"VehicleID\" => \"d33182ba-beb3-48dc-934f-ffb157aa815e\"\n  ]\n]\n

what could be wrong? how can i debug this?

0 likes
5 replies
pllaguno's avatar

I am kind of new to laravel, i get this on the log files.

Add [0] to fillable property to allow mass assignment on [App\Pemex].

i need to have all of the fields on fillable model?

pllaguno's avatar

I added all the columns into the fillable method onthemodel and nowi am getting

[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near ')'. (SQL: insert into [Pemex] () values ())

I have no idea why the query is blank

Reached's avatar

Seems like your new issue is related to your config, could you post your database config?

audunru's avatar
audunru
Best Answer
Level 4

Also wondering about what you're actually passing in the request... Is it a nested array?

Does

$Pemex = Pemex::create([
    "Economico" => "TLN-42"
    // anything else you need
]);

work? Or give a different error?

pllaguno's avatar

that helped, the problem was it was on an array, thanks for pointing that out.

Please or to participate in this conversation.