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

bobdebower's avatar

get request extrene api in Laravel

heys guys, i want to make a get request from a extrene api and create a endpoint using postman.

so i want make a get request in postman. with a address and i want to be able add a key and value in postman . With this creating a endpoint. But how do i do this in my [web.php or api.php route]??

How i do it now is like this. i just paste the url endpoint below but i want to do this with the route and postman.

     public function show(Configuration $configuration)
      {
    $cool = $this->authenticate()->get('my end point static')->json();

please help me

0 likes
4 replies
assoft's avatar
assoft
Best Answer
Level 4

routes/api.php

Route::get('my-custom-api-url', function(Request $request, Configuration $configuration){
	return response()->json([
		"message" => "success",
		"request" => $request->all(),
		"configuration" => $configuration
	], 200);
});

1 like
bobdebower's avatar

Thanks for your respond. just forget about the configuration data, how do i make the request with postman? creating a endpoint

assoft's avatar

Assuming you are using Valet;

  1. Open postman
  2. Create new request
  3. Set request type (get, post, etc..)
  4. Set request url: http://your-app.test/api/my-custom-api-url

Note: Sure it's open to the public

If you want to send a request to an authorized backend, you need to use auth middleware.

Sanctum Documentation; https://laravel.com/docs/8.x/sanctum

Sanctum Tutorial: https://laracasts.com/series/whats-new-in-laravel-7/episodes/6

sample:

Route::get('my-custom-api-url', function(Request $request, Configuration $configuration){
	return response()->json([
		"message" => "success",
		"request" => $request->all(),
		"configuration" => $configuration
	], 200);
})->middleware("auth");

In this case, you will prevent unauthorized requests.

Did this help you?

bobdebower's avatar

Thank you so much for reply it helped. but i still have a question. i think i need a post request. Because iam building a converter. i want to get the data(json) that needs to be converted to xml from a externe api.

( i currently have it like this)

in my api/route

Route::post('MyCustomApiUrl', ApiController::class);

and i this is the methode i want to use to convert json to xml from the requested url(route).

so i want to be able to get the data from a externe api and convert the xml using my api call.

// i think it looks like this but not sure.

   public function index()
     {
 
    $data= data;

    $result = ArrayToXml::convert($data, 'config', true, 'UTF-8');

    return response($result)->header('Content-Type', 'text/xml');

    }

Please or to participate in this conversation.