1

Tested as described in this Stack post: Not working on Laravel Controller, Working on Tinker

The original is a very simple CURL request:

curl -H "Authorization: Bearer 1G5bv.m*******"
     -H "Content-Type: application/json"
     -X POST https://testdashboard.com/api/reporting/314****/6912****/submit/202314*****

I used the Laravel Http facade (also tried native PHP curl with same result). With a var_dump before the URL is exact, and the token is correct.

$response = Http::withHeaders([
    'Authorization' => 'Bearer '.$this->auth_data['token'],
    'Content-Type' => 'application/json'
])->post($url);

However, when using the above HTTP in tinker, it works, inside my Laravel job I get a 500 error from the server. I have reached out to the server devs, pending response

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
TDawg
  • 833
  • 2
  • 8
  • 24
  • 1
    Yep, a 500 error requires the server devs to take a look in their logs. Normally in a Laravel application you need to check the laravel.log. what you could do is check your own laravel.log and see if you have any errors. If Postman works with their Api then it becomes interesting – UnderDog May 24 '23 at 17:15
  • 1
    Without an error, we can't do anything at all. So you have to update the question with the dev's response. Next time, wait for the response and then post as this question could get closed, and then you would have to edit it and try to reopen it... Maybe you read the error and is so obvious that you do not require to post a question at all, so next time wait for it... And the title says it is not working on tinker but on the question you mentioned that is it working on tinker but not on a job, so... which one is correct? fix it please – matiaslauriti May 24 '23 at 17:29

0 Answers0