jeudi 15 décembre 2022

Server error: `POST https://my-api-url` resulted in a `500 Internal Server Error

So i have this error where it says that

"Server error: POST https://my-api-url resulted in a 500 Internal Server Error resulted in a 500 Internal Server Error` response: {"fault":{"faultstring":"Execution of JS-SetCreator failed with error: Javascript runtime error: "SyntaxError: Unexpect (truncated...)

the error

The function:

 public function store()
  {
    $client = new Client();
    $url = "https://my-api-url";
    $token = Token::latest()->first()->access_token;
    $json = '{
      "resourceType": "Medication",
      "meta": {
        "profile": [
          "https://some-url"
        ]
      },  "identifier": [
        {
          "system": "url",
          "use": "official",
          "value": "123456789"
        }
      ],
// ...
}';

$jsonArray = json_decode($json, true);
    $response = $client->post($url, [
      'headers' => [
        'Authorization' => 'Bearer ' . $token,
        'Accept' => 'application/json'
      ],
      'form_params' => $jsonArray,
    ]);
    $response = json_decode($response->getBody());
}

I'm trying to make a POST request to the given URL but ended up with those errors. I've tried in postman but it's working fine, so I guess there's something wrong with my code

Here's the not truncated error

{"fault":{"faultstring":"Execution of JS-SetCreator failed with error: Javascript runtime error: \"SyntaxError: Unexpected token: r. (SetCreator.js:5)\"","detail":{"errorcode":"steps.javascript.ScriptExecutionFailed"}}}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/uweZygc
via IFTTT

Aucun commentaire:

Enregistrer un commentaire