Highlighted
Super Contributor.
Super Contributor.
69 views

Restful api requests from another site

Hello
I want to work with REST requests to HPSM from another site.
From the browser - it works
From JMeter - works great too
But from my React application does not work.
I use:

 

 

axios.get ('/SM/9/rest/incidents', {
   method: "GET",
   baseURL: "http://hpserver:13080",
   headers: {
      "Authorization": "Basic RmFsY29uOkZnhmeA==",
      "Content-Type": "text / plain"
   }
})

 

 

error:

Access to XMLHttpRequest at 'http://hpserver:13080/SM/9/rest/incidents' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

 

 

I know there is a way - you need to change the restful server
"Access-Control-Allow-Origin" : "*"
But how to do that?

Maybe there is another way?

0 Likes
2 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: Restful api requests from another site

Hello,

 

I hope you are doing great.

 

Here you can find information regarding REST: 

https://docs.microfocus.com/itom/Service_Manager:9.64/RestSyntax

 

There, you can find information about syntax and commands for REST requests.

 

Unfortunately, it does not mention the usage of REST on external applications.

But, since you mentioned that the request works on browser and JMeter, is there an specific reason for using React?

 

Let us know your comments.

 

Have a nice day,

 

0 Likes
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: Restful api requests from another site

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.