userId in first post snippet should be user_id
Dec 19, 2019
7
Level 1
Lumen data validation fails
I'm validating data sent via Guzzle post request but validation fails. I've logged the data and i can see that it exists but validation rule exists fails. Basically i'm trying to send data from one lumen project to another using a Guzzle POST request.
This class has code to send data
<?php
public function sendData() {
$user_id = 123;
$email = '[email protected]';
$data = ['userId' => $user_id, 'email' => $email];
$this->guzzlePost('API TO RECEIVE THE DATA', $data); // From Guzzle trait
}
This code is a different lumen project to receive data
<?php
public function receiveData(Request $request) {
$validator = Validator::make($request->all(), [
'user_id' => 'required|exists:myuser_table,id',
'email' => 'required|unique:myuser_table,email'
]);
if ($validator->fails()) {
throw new \Illuminate\Validation\ValidationException($validator);
} else {
return 'Data received';
}
}
Please or to participate in this conversation.