Page 1 of 1

Python JSON WSP: "Faulty API Request"

Posted: Wed Apr 10, 2024 4:37 pm America/New_York
by eshreth_of_athshe
I'm trying to pull data from NLDAS_NOAH0125_H via JSON Web Service Protocol subset request. However, I'm getting a request fault and I've failed to narrow down why.

My main question is this: can I extract a JSON from valid requests in the subsetter or some other tool to use as a reference? I don't know what's wrong with the request I'm making, and I'd like to see other valid requests. If that's not possible, I'd appreciate any thoughts on what I'm doing wrong with my subset request.

Here's the code I have at the moment; I've tried to change the JSON to fit my use case, but like I said, the request raises a fault. I've been following the example "How to Use the Web Services API for Dataset Searching" at:
The URL for the data product is:

# Define the parameters for the data subset
product = 'NLDAS_NOAH0125_H'
begTime = '2000-01-01T00:00:00.000Z'
endTime = '2000-01-02T00:00:00.000Z'
minlon = -122.0
maxlon = -116.0
minlat = 33.0
maxlat = 38.0
varName = 'SoilM_40_100cm'

# Construct JSON WSP request for API method: subset
subset_request = {
'methodname': 'subset',
'type': 'jsonwsp/request',
'version': '1.0',
'args': {
'role': 'subset',
'start': begTime,
'end': endTime,
'box': [minlon, minlat, maxlon, maxlat],
'crop': True,
'data': [{'datasetId': product,
'variable': varName

I also altered the example's get_http_data() to provide more detail in the cause of a faulty request, as shown below.

def get_http_data(request):
hdrs = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = json.dumps(request)
r = http.request('POST', svcurl, body=data, headers=hdrs)
response = json.loads(

# Check for errors
if response['type'] == 'jsonwsp/fault':
self.logger.error('API Error: faulty request. Here is the response:')
self.logger.error(json.dumps(response, indent=4))
sys.exit('API Error: faulty request, exiting...')
return response

The output of which is:

2024-04-10 13:30:39,549:get_http_data:{
"type": "jsonwsp/fault",
"version": "1.0",
"fault": {
"code": "server",
"string": "Failed to find a service configuration matching requested constraints."

Re: Python JSON WSP: "Faulty API Request"

Posted: Tue Apr 16, 2024 11:20 am America/New_York
by mgreene

Our data and subject matter experts will examine your question and formulate a reply shortly.

To subscribe to our monthly announcements mailing list, send a message with “Subscribe” in the Subject line to . You may also subscribe to the list on this page: