webwrite returns status 405 "Method not Allowed"

13 ビュー (過去 30 日間)
Lane Bekow
Lane Bekow 2019 年 2 月 16 日
編集済み: Madheswaran 2024 年 11 月 19 日 9:05
Hi Everyone,
I work in x-ray scattering and have to reference various material properties often. I'd like to try to automate this process by being able to directly download the data from this online database and assign it to a variable or two in matlab. The issue I'm having is this database requires user input before it will lookup or calculate the needed results. Here is an example of this form: http://henke.lbl.gov/optical_constants/pert_form.html
I'd like a funtion in MATLAB that would take the two user intput 'Element' and 'Energy' and submit them to this form and return all the information under the 'Atomic Proeprties' and 'Material Properties' sections of the next page.
I've been quickly overwhelmed by the properties of webread/webwrite and all the RESTful web services or JSONs. All I've been able to do so far is read in the html file by calling
response = webread('http://henke.lbl.gov/optical_constants/pert_form.html')
From what I've read, it seems like this database is using POST to request data from the user, but I haven't been able to successfully post anything to this form. When I try to post with webwrite I get the following error
>> webwrite('http://henke.lbl.gov/optical_constants/pert_form.html','post',{'Element','Si'})
Error using readContentFromWebService (line 46)
The server returned the status 405 with message "Method Not Allowed" in response to the request to URL
http://henke.lbl.gov/optical_constants/pert_form.html.
Error in webwrite (line 139)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
I'm not sure what exactly the issue is or how to proceed. Any adviced is greatly appreciated.
  1 件のコメント
J E
J E 2022 年 9 月 13 日
編集済み: Rena Berman 2022 年 9 月 13 日
I'm having the same issue - did you ever find a solution? Thanks! 2

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

回答 (1 件)

Madheswaran
Madheswaran 2024 年 11 月 19 日 9:05
編集済み: Madheswaran 2024 年 11 月 19 日 9:05
I assume that you would like to get the X-Ray properties of the different elements from https://henke.lbl.gov/optical_constants/pert_form.html. However you are making a direct post call to the site, which the server rejects it. As you can notice from the website when you submit the querry, a post call with the filled form data is sent to https://henke.lbl.gov/cgi-bin/pert_cgi.pl.
You can get the X-Ray properties of the element with the following MATLAB Command:
data = "Element=Si&Energy=1000";
response = webwrite('https://henke.lbl.gov/cgi-bin/pert_cgi.pl', data);
For more information, refer to the following documentation: https://mathworks.com/help/matlab/ref/webwrite.html
Hope this helps!

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by