Borrar filtros
Borrar filtros

Add basic Authorization in Matlab script

3 visualizaciones (últimos 30 días)
Dion Theunissen
Dion Theunissen el 12 de Ag. de 2022
Respondida: Piyush Dubey el 3 de Jul. de 2023
I try to realize a PUT api in matlab. I have allready this part which is working: = "e37b35dd-4aca-4ecb-8972-55c3a27a8b11";
data = jsonencode(s,PrettyPrint=true)
% data = jsondecode(s,Prettyprint=true);
body =;
% authorizationField =,password)
contentTypeField ='application/json');
header = [contentTypeField]
method =;
uri = ""
request =,header,body);
resp = send(request,uri)
But now i need to add mu authorization. This is a basic authorization (username and password). How can i put this in the header from the script above?

Respuestas (1)

Piyush Dubey
Piyush Dubey el 3 de Jul. de 2023
Hi Dion,
AuthorizationFieldclass can be used to add authorization in header of a MATLAB script.
This is a sample code demonstrating its usage:
credentials =, password);
authorizationField =;
header = [contentTypeField, authorizationField];
Follow the documentation link below to know more aboutAuthorizationField’ class:
Hope this helps.


Más información sobre Call Web Services from MATLAB Using HTTP en Help Center y File Exchange.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by