jswoolf01's avatar

Testing a function call that uses Http::attach()?

I'm trying to debug a feature that involves sending data from one Laravel app to another, using a url call.
Specifically, I'm testing a function that sends a record of a sale from a point-of-sale app to a separate app that maintains inventory. The point-of-sale app writes the sale information to a csv, then attaches that csv to an API call to the inventory app. I've established that the csv is getting written right; now I need to find out if the inventory app is receiving it. The only way I can think of to test this is to reproduce the call using Postman (or something similar), but I don't know how to do that. This is what the source function looks like:

private function sendOrderToInventory($orderId, $filePath)
    {
        $url = env('REMOTE_SERVER_URL') . '/pos-orders/import';

        $response = Http::attach('order_upload', file_get_contents($filePath), $orderId . '.csv')
            ->post($url, [
                'api_key' => env('INVENTORY_API_KEY')
            ]);

        return $response;
    }

(The given $url gets routed to the api function I'm trying to test.)

How do I turn this into a postman request that I can send, so I can see what the receiving api function is doing? In particular, what do I do with the Http::attach() part?

0 likes
0 replies

Please or to participate in this conversation.