Goal
With Nodejs support , the file should be streamed via the body
Section -1
Accept a HTTP POST request which will contain the following JSON in its body:
{ event, entity, actor, machines, tests, options }
I am interested in the event (‘completed’) and entity (‘job’).
Section -2
Then I'II call back the HTTP domain name mentioned in the actor with the following call:
URL = actor + /api/logs/:id
Where id will be options.id that received in the previous callback.
This will give back the JSON of all the log files generated for that job.
Section -3
I can then generate the full path for any log that I want:
URL = actor + logs/:id/:path
I can then process the log and create final log.
Section -4
Once I am are ready,
I should do a HTTP post request to:
URL = actor + logs + :id + :name

 採用された回答

Kojiro Saito
Kojiro Saito 2021 年 6 月 29 日

1 投票

I'm not sure which parameters should you post to NodeJS, but about Section 1 and 2, it might be the following.
%% Section 1
url = 'http://localhost:3000/postTest'; % To be replaced by your actual endpoint
data = struct('data', 1); % To be replaced by your actual json data
res = webwrite(url, data);
%% Section 2
url2 = "http://localhost:3000/" + res.actor + "/api/logs/:" + res.options.id;
% To be replaced by your actual endpoint
data2 = struct('data', 2); % To be replaced by your actual json data
res2 = webwrite(url2, data2); % If it is GET request, it would be res2 = webread(url2);

7 件のコメント

Life is Wonderful
Life is Wonderful 2021 年 6 月 29 日
編集済み: Life is Wonderful 2021 年 6 月 29 日
Thanks a lot. Make lot of sense with pseudo code .
I was wondoring what could be the url for
URL = actor + logs/:id/:path
I am not sure here [Two structure element one after another]
url3 = "http://localhost:3000/" + res.actor + "/api/logs/:/:" + res.options.id.path;
Thanks
Kojiro Saito
Kojiro Saito 2021 年 6 月 29 日
How about this?
url3 = "http://localhost:3000/" + res.actor + "/api/logs/:" + res.options.id + "/:" + res.options.id.path;
Life is Wonderful
Life is Wonderful 2021 年 6 月 30 日
I could imagine something like below,
although i am not sure if the interpretation/which perspective is the right one
URL = actor + logs/:id/:path % Requirement
url3 = [res.actor] + [res.options.id] + [res.options.id.path]; % Your proposal
url3 = [res.actor] + [res.options.id.path]; % My proposal
Kojiro Saito
Kojiro Saito 2021 年 6 月 30 日
I am not sure which one is correct. It's not a matter of coding, but a matter of API implementation of server side. You need to refer your NodeJs programs or ask someone who knows the API in detail.
Life is Wonderful
Life is Wonderful 2021 年 6 月 30 日
Thanks !
Can you please help me and I am not clear on the code
Accept a HTTP POST request which will contain the following JSON in its body
should have HTTP requestmethod POST or GET to get the JSON data ?
Kojiro Saito
Kojiro Saito 2021 年 6 月 30 日
Both HTTP GET and POST receices JSON data from server. You can try by using webread (HTTP GET) and webwrite (HTTP POST).
Life is Wonderful
Life is Wonderful 2021 年 7 月 2 日
Thank you! In case I need further information please help me

サインインしてコメントする。

その他の回答 (0 件)

製品

リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by