Configure web page using JQuery POST to Geoevent JSON on REST

2944
2
Jump to solution
07-29-2015 09:15 AM
KevinKingrey
New Contributor

I’m trying to configure a web page to send data from our iPads in the field back to the GEP for analysis and mapping.  I have the page doing a POST back to the REST input.  It works as expected on my desktop machine, but does not from the iPads. From what I’ve seen so far in research is that I need to enable CORS to allow this to work.  Are there any examples on how to properly enable CORS for the GEP and how this can be accomplished, or is it not possible to get data to GEP from a JQuery POST?

Any help would be greatly appreciated!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RJSunderman
Esri Regular Contributor

Hello Kevin -

Thanks for reaching out. I am going to need some additional information from you.

I'm assuming you have developed a JavaScript application using the JQuery library ... and that you are able to use your application to POST JSON to the REST endpoint hosted by the GeoEvent Extension, running your application on your desktop, and the intended GeoEvent input receives the JSON event data. But when you run your application from the iPad you are returned some sort of HTTP error? Can you tell me what the returned error message is?

I'm not familiar with Cross-origin resource sharing (CORS). I read a little about it on the HTTP access control (CORS) page on the Mozilla Developer Network. Usually when I'm asked about a client making an HTTP POST request to GeoEvent the issue is that the server is behind some sort of firewall and the client (or external server) cannot reach the GeoEvent REST endpoint. The issue is normally that the client or external server simply cannot see the server running GeoEvent, not a cross-domain restriction on specific resources.

I spoke with one of the developers who suggested to me that CORS is enforced by the browser, on the client, to prevent malicious code from being downloaded to the client. I don't think GeoEvent Extension particularly cares who or what is posting to its input's REST endpoint. The input's transport delivers a payload to the adapter, and if the adapter can interpret the received JSON it proceeds to create a GeoEvent.

Using a Firefox browser, I used the poster-extension to make an OPTIONS request on the administrative endpoint for my GeoEvent input. I was returned an HTTP 200 / OK message that the operations  POST, GET, DELETE, PUT, OPTIONS, and HEAD were all allowed.

The person I'd like to review this with is unavailable until August 17th. I don't have any examples on enabling CORS for GeoEvent. I'll see what I can do to have someone look into JQuery POST requests and get back with you.

Best Regards -

RJ

View solution in original post

0 Kudos
2 Replies
RJSunderman
Esri Regular Contributor

Hello Kevin -

Thanks for reaching out. I am going to need some additional information from you.

I'm assuming you have developed a JavaScript application using the JQuery library ... and that you are able to use your application to POST JSON to the REST endpoint hosted by the GeoEvent Extension, running your application on your desktop, and the intended GeoEvent input receives the JSON event data. But when you run your application from the iPad you are returned some sort of HTTP error? Can you tell me what the returned error message is?

I'm not familiar with Cross-origin resource sharing (CORS). I read a little about it on the HTTP access control (CORS) page on the Mozilla Developer Network. Usually when I'm asked about a client making an HTTP POST request to GeoEvent the issue is that the server is behind some sort of firewall and the client (or external server) cannot reach the GeoEvent REST endpoint. The issue is normally that the client or external server simply cannot see the server running GeoEvent, not a cross-domain restriction on specific resources.

I spoke with one of the developers who suggested to me that CORS is enforced by the browser, on the client, to prevent malicious code from being downloaded to the client. I don't think GeoEvent Extension particularly cares who or what is posting to its input's REST endpoint. The input's transport delivers a payload to the adapter, and if the adapter can interpret the received JSON it proceeds to create a GeoEvent.

Using a Firefox browser, I used the poster-extension to make an OPTIONS request on the administrative endpoint for my GeoEvent input. I was returned an HTTP 200 / OK message that the operations  POST, GET, DELETE, PUT, OPTIONS, and HEAD were all allowed.

The person I'd like to review this with is unavailable until August 17th. I don't have any examples on enabling CORS for GeoEvent. I'll see what I can do to have someone look into JQuery POST requests and get back with you.

Best Regards -

RJ

0 Kudos
KevinKingrey
New Contributor

RJ,

Thanks so much for your comprehensive response.

I have been working with the application over the last few days and decided to dig deeper in to the server setup and firewall configuration to see if everything was setup properly.  The server I am working with is a new one we just setup this year that is to take some of the load from our one main server we still have.  GEP is setup on both of them and I was under the impression the new server had the same permissions and allowances through our firewall as the old server.  This was not the case.  After checking again with our IT department we discovered that port 6180, which was the port I was posting to, was not allowed through our firewall.  After this was fixed, everything worked as expected and no CORS settings were needed.

Thanks to your response and comment about the firewall, it directed me to the root of the problem.

Best Regards,

Kevin

0 Kudos