Ambiguity in accessing Granule Subset web service.

Ambiguity in accessing Granule Subset web service.

Postby omkarr » Sun Apr 02, 2017 10:43 am

Hi,

I have been trying to use the Granule Subset web service here[0]. I have been using the same code mentioned in the same page. But I have been getting an error at the line

Code: Select all
print data
result = json.loads(data)


The print statement prints the following :

Code: Select all
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://podaac.jpl.nasa.gov/ws/subset/granule?request=submit">here</a>.</p>
</body></html>


The above output clearly points out that the document has been moved to the url : https://podaac.jpl.nasa.gov/ws/subset/g ... est=submit. This error is being seen even though we are using the same url(that is mentioned in the above output) in the code. Please look into it.

Thanks,
Omkar.

[0] https://podaac.jpl.nasa.gov/ws/subset/g ... index.html
omkarr
 
Posts: 25
Joined: Wed Jun 15, 2016 12:34 am

Re: Ambiguity in accessing Granule Subset web service.

Postby mgangl » Tue Apr 04, 2017 9:02 am

Thanks for the report! We recently implemented a redirect from http -> https due to a government security mandates. This is why you're getting the "document has moved" message. Unfortunately we still need to update more of our documentation to catch and fix these issues.

Are you saying when using the "https..." link, you're still getting the "document moved" message?
mgangl
 
Posts: 12
Joined: Wed Apr 27, 2016 1:31 pm

Re: Ambiguity in accessing Granule Subset web service.

Postby omkarr » Tue Apr 04, 2017 9:56 am

Hi,

Thank you very much for your reply. I have updated my code to use https. I have also changed the line in the code :
Code: Select all
conn = HTTPConnection("podaac.jpl.nasa.gov")
to
Code: Select all
conn = HTTPSConnection("podaac.jpl.nasa.gov")

Now, I am receiving the error as follows : Unexpected Error Occured
omkarr
 
Posts: 25
Joined: Wed Jun 15, 2016 12:34 am

Re: Ambiguity in accessing Granule Subset web service.

Postby omkarr » Tue Apr 11, 2017 12:42 am

[PING] Can someone look into this soon? This has been a blocker for us at podaacpy.

Thanks,
Omkar.
omkarr
 
Posts: 25
Joined: Wed Jun 15, 2016 12:34 am

Re: Ambiguity in accessing Granule Subset web service.

Postby mgangl » Tue Apr 11, 2017 6:18 am

Hello, we've resolved the issue. Can you please try your script again? The example script at https://podaac.jpl.nasa.gov/ws/subset/g ... index.html will work if you use:

Code: Select all
conn = httplib.HTTPSConnection("podaac.jpl.nasa.gov")


instead of

Code: Select all
conn = httplib.HTTPConnection("podaac.jpl.nasa.gov")


Here's the full code example
Code: Select all

#!/usr/bin/python

import sys,math
import httplib, urllib
import json, time



def main(argv):
   #load input file that contins subsetting instruction and submit subset request

   #read input file
   f = open('input.json', 'r+')
   input = json.load(f)
   inputString = json.dumps(input)

   # submit subset request
   params = urllib.urlencode({'query':inputString})
   headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "*"}
   conn = httplib.HTTPSConnection("podaac.jpl.nasa.gov")
   conn.request("POST", "/ws/subset/granule?request=submit", params, headers)
   response = conn.getresponse()
   
   data = response.read()
   print data
   result = json.loads(data)
   token =  result['token']
   conn.close()


   #check status on the submitted job until ready

   flag = True
   while (flag):
      conn = httplib.HTTPSConnection("podaac.jpl.nasa.gov")
      conn.request("GET", "/ws/subset/status?token="+token, params)
      response = conn.getresponse()
      data = response.read()
      conn.close()
      result = json.loads(data)
      status = result['status']
      print data
      if (status == 'done') or (status == 'error'):
          flag = False

      time.sleep(1)

   print "Good bye!"


if __name__ == "__main__":
   main(sys.argv[1:])
mgangl
 
Posts: 12
Joined: Wed Apr 27, 2016 1:31 pm

Re: Ambiguity in accessing Granule Subset web service.

Postby omkarr » Wed Apr 12, 2017 12:58 am

Hi,

Everything is working good now. Thanks for the help.

Regards,
Omkar.
omkarr
 
Posts: 25
Joined: Wed Jun 15, 2016 12:34 am

Re: Ambiguity in accessing Granule Subset web service.

Postby juanca21 » Sun Dec 10, 2017 5:29 am

Hi guys! thanks for this information! ;)


Regards



att Juanca.
Great forum! :)
juanca21
 
Posts: 3
Joined: Sun Dec 10, 2017 5:21 am


Return to PO.DAAC Web Services

cron