-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
function response = sendRequest(parameters, token, endpoint) | ||
function response = sendRequest(parameters, token, endpoint, timeout) | ||
% This function is undocumented and will change in a future release | ||
|
||
%sendRequest Sends a request to an ENDPOINT using PARAMETERS and | ||
% api key TOKEN. | ||
%sendRequest Sends a request to an ENDPOINT using PARAMETERS and | ||
% api key TOKEN. TIMEOUT is the nubmer of seconds to wait for initial | ||
% server connection. | ||
|
||
% Copyright 2023 The MathWorks, Inc. | ||
|
||
% Define the headers for the API request | ||
|
||
headers = [matlab.net.http.HeaderField('Content-Type', 'application/json')... | ||
matlab.net.http.HeaderField('Authorization', "Bearer " + token)]; | ||
% Define the request message | ||
request = matlab.net.http.RequestMessage('post',headers,parameters); | ||
% Send the request and store the response | ||
response = send(request, matlab.net.URI(endpoint)); | ||
arguments | ||
parameters | ||
token | ||
endpoint | ||
timeout | ||
end | ||
|
||
% Define the headers for the API request | ||
|
||
headers = [matlab.net.http.HeaderField('Content-Type', 'application/json')... | ||
matlab.net.http.HeaderField('Authorization', "Bearer " + token)]; | ||
|
||
% Define the request message | ||
request = matlab.net.http.RequestMessage('post',headers,parameters); | ||
|
||
% Create a HTTPOptions object; | ||
httpOpts = matlab.net.http.HTTPOptions; | ||
% Set the ConnectTimeout option | ||
|
||
httpOpts.ConnectTimeout = timeout; | ||
% Send the request and store the response | ||
response = send(request, matlab.net.URI(endpoint),httpOpts); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters