webwrite returns status 405 "Method not Allowed"

14 views (last 30 days)
Lane Bekow
Lane Bekow on 16 Feb 2019
Edited: Madheswaran on 19 Nov 2024 at 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 Comment
J E
J E on 13 Sep 2022
Edited: Rena Berman on 13 Sep 2022
I'm having the same issue - did you ever find a solution? Thanks! 2

Sign in to comment.

Answers (1)

Madheswaran
Madheswaran on 19 Nov 2024 at 9:05
Edited: Madheswaran on 19 Nov 2024 at 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!

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!