Solved.
Issue was the way i was formatting my request.
my trans was actually a field, and the value was the json string containing the data.!
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi All,
I have a laravel API that accepts form data as json. Form data is being put together by native android application (Java). This form is multi part data, so it sends string and also a file.
I believe the issue is with the way my JSON body is formatted as i was informed that the json field must be part of the form data, the field name is trans, but unsure of what that means.
I take my request and decode it before running a script that grabs each part of the form and prepares to write it to database
$file = $request->file('sig');
$transjson = $request->trans;
$trans = collect(json_decode($transjson,true));
My Request
Content-Disposition: form-data; name="trans"
Content-Transfer-Encoding: binary
Content-Type: text/plain; charset=utf-8
Content-Length: 254
{"card":"12345","client":12","load_type":"test","site_location":"test","date":"2018-05-27T09:00:00"}
Content-Disposition: form-data; name="sig"; filename="test.png"
Content-Type: multipart/form-data
Content-Length: 3128
Response
{
"message": "{\"trans\":[\"The trans field is required.\"],\"sig\":[\"The sig field is required.\"]}"
Thanks!
Solved.
Issue was the way i was formatting my request.
my trans was actually a field, and the value was the json string containing the data.!
Please or to participate in this conversation.