I have tried the canonical example (with the real API Key)
apiEndpoint = "https://api.openai.com/v1/chat/completions";
apiKey = "myAPIKey1234567";
(*Create the payload for the POST request*)
payload =
ExportString[<|"model" -> "gpt-4",
"messages" -> {<|"role" -> "user",
"content" -> "What is the weather in Prague today?"|>}
, "max_tokens" -> 50, "temperature" -> 0.7
|>, "JSON"
];
(*Perform the HTTP POST request*)
response =
URLExecute[
apiEndpoint, {"Method" -> "POST",
"Headers" -> {"Content-Type" -> "application/json",
"Authorization" -> "Bearer " <> apiKey}, "Body" -> payload}];
however the Mathematica 13.2 returned the error message
URLExecute::nvldarg: The argument Content-Type->application/json should be a string
But what is the correct way to send send authentication in the required format?
URLExecute. TryURLExecute @ HTTPRequest[....$\endgroup$