Category : postman

I’m planning to randomize the order of my query on quiz_question and choices but the quiz_question is the only one who gets randomized but the choices are still the same. This is my code : class QuestionByQuizID extends Controller { public function index(int $quiz_id){ $questions = quizQuestions::where(‘quiz_id’, ‘=’, $quiz_id)->with([‘choices’])->inRandomOrder()->get(); if(is_null($questions)){ return response()->json(‘Record not found!’, 401); ..

Read more

In postman there is an option to send binary datatype in a api. I am sending that in a api where but i am unable to detect that binary file in laravel request method. curl –location –request POST ‘http://192.168.*.*/api/v1/contact_us/save’ –header ‘Authorization: Bearer some_key’ –header ‘Content-Type: image/jpeg’ –data-binary ‘@/Users/username/Desktop/filename.jpeg’ Above is my curl code generated in ..

Read more

I’ve a macbook pro with M1 chipset, I’m testing a Laravel web-app with Sanctum Api authentication. First I send a GET requesto to ‘/sanctum/csrf-cookie’ to get the cookies, then I send a POST request to the ‘/login’ endpoint I get the following error: "IlluminateDatabaseQueryException: could not find driver (SQL: select * from "users" where "email"" ..

Read more

i have alot of records that needs to be edited in one request, so i went for POST request to try to edit the data in my controller like this : foreach ($attr as $key){ foreach ($key->item as $attribute) { if ($attribute[‘action’] == ‘store’) { $insert_array = [ ‘subject_quiz_id’ => $key->subject_quiz_id, ‘registration_record_id’ => $attribute->registration_record_id, ‘mark’ ..

Read more

I am developing REST APIs for my project in Laravel 6.*. The problem is that my APIs are working in Postman Chrome Extention and web browser but not in Native Desktop Application. I’m am serving my laravel app. by using php artisan serve command. the The error which i got in postman console Sourc..

Read more

Hello to everyone who is seeing this! I am a Laravel beginner, using Laravel for API-s calls. I cannot find an appropriate solution how to pick up parameters from GET method that looks like this: http://localhost:8000/api/products/searchv2/cat=category1&cat=category2 Now I want to receive in my Laravel controller this array $categories = ["category1", "category2"] I think the solution ..

Read more

public function register(Request $request) { // $user = User::create([ // ‘name’ => $request->input(‘name’), // ’email’ => $request->input(’email’), // ‘password’ => Hash::make($request->input(‘password’)) // ]); // // return $user; return "test"; } Hi all, basically, I’m trying to build a restful API with Laravel and my API is being hit by Postman, but when I send a ..

Read more

I’m developing a REST service with Laravel to consume it from a mobile app. It works properly on local, but not on hosting. After several tries, I developed a basic example to test the POST method, but it returns the same error. api.php file Route::post(‘/test’, [‘uses’ => ‘[email protected]’]) ; testController.php file namespace AppHttpControllersApi; use AppHttpControllersController; ..

Read more

ProductController.php class ProductController extends Controller { public function index(Request $request) { $limit = $request->has(‘limit’) ? $request->get(‘limit’) : 10; $offset = $request->has(‘offset’) ? $request->get(‘offset’) : 0; $products = Product::offset($offset)->limit($limit)->get(); return new ProductResource($products); } //Search Products public function search($name, Request $request) { $limit = $request->has(‘limit’) ? $request->get(‘limit’) : 10; $offset = $request->has(‘offset’) ? $request->get(‘offset’) : 0; $products ..

Read more

I am beginner of react program. I am just building one small webapp using Laravel and React. I suddenly got error I dont know what i did wrong. If anyone help me i will be glade to you. Bellow the error message: Access to XMLHttpRequest at ‘http://127.0.0.1:8000/sanctum/csrf-cookie’ from origin ‘http://localhost:3000’ has been blocked by CORS ..

Read more

Running activate method with sanctum id parameter I see that id parameter is not passed into activate control action. In routes/api.php : Route::middleware(‘auth:sanctum’)->group( function () { Route::post(‘logout’, [AuthController::class, ‘logout’]); Route::resource(‘ads’, AdController::class); Route::put(‘ads/{id}/activate’, [AdController::class, ‘activate’]); }); In postman I pass parameter as http://server.com/api/ads/7/activate, but problem is that in app/Http/Controllers/API/AdController.php : public function activate(Request $request, Ad $ad) ..

Read more

I am trying to generate a PDF that will contain Chinese characters using dompdf and hence I downloaded the font package and added the following code in my blade.php. @font-face { font-family: ‘simhei’; font-style: normal; font-weight: normal; src: url(‘{{base_path().’/public/fonts/’}}’simhei.ttf) format(‘truetype’); } body { font-family: ‘simhei’, ‘DejaVu Sans’, sans-serif; } Next, I tried the API again ..

Read more

in need of assistance i have an update function in my controller $client->update($request->all()); return response([‘client’ => new ClientResource($client), ‘message’ => ‘Update successfully’], 200); when i try updating my from postman , it updates with the params section in post man but doesn’t update in form data. how it that a problem? consuming the api with ..

Read more

I am working with Laravel API. Whenever I call JWTAuth::parseToken()->(..) it throws the inbuilt exception and display inbuilt exception handler message. Even if I put separate catch block for each token exception. Here is my code. try { if (! $user = JWTAuth::parseToken()->authenticate()) { return response()->json([‘user_not_found’], 404); } } //Token Expire catch ( TokenExpiredException $exception ..

Read more