question

af-data avatar image
af-data asked David Marginian Deactivated answered

Creating Exports for orders and payments

Just trying to export sales data from clover api.

I am working off the code submitted in github export-api-examples repository .

I am able to create the export successfully. But when I execute the function to get the export, it doesn't return a url to access the url.


def api_url(resource_path):
    """Generate the URL for an API call"""
    return "{}{}?access_token={}".format(HOST, resource_path, ACCESS_TOKEN)

def create_export(export_type, start_time, end_time):
    """Request a new export"""
    url = api_url("/v3/merchants/" + MERCHANT_ID + "/exports/")

    payload = {
        "type": export_type,
        "startTime": start_time,
        "endTime": end_time,
    }
    resp = requests.post(url, json=payload)
    resp.raise_for_status()

    return resp.json()

def get_export(export_id):
    """Get the current state of the specified export"""
    url = api_url("/v3/merchants/" + MERCHANT_ID + "/exports/" + export_id)

    resp = requests.get(url)
    resp.raise_for_status()

    return resp.json()


Running these functions returns:

{'id': 'VJS1YC61KWF1W',
 'type': 'PAYMENTS',
 'status': 'DONE',
 'percentComplete': 100,
 'availableUntil': 1624711390000,
 'startTime': 1624511000,
 'endTime': 1624597000,
 'createdTime': 1624624981000,
 'modifiedTime': 1624624990000,
 'exportUrls': {'elements': []},
 'merchantRef': {'id': 'NZ492DDYP2AY1'},
 'retryCount': 0}


'exportUrls': the values of `elements` should return a url or urls not an empty list.


Help?




REST API
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered

You are using 10 digit timestamps, we use Unix with millis 13 digits and I expect that is the problem. Your timestamp is wrong and there is not data to export. Please note the start/end time in our script verse yours (https://github.com/clover/export-api-examples/blob/master/python/create_export.py)

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented

Are you checking the response? From our logs, I see you are getting a 503 for the export request:

The export service is not available at this time. The allowed times for creating exports are (UTC): MON-FRI 10:00-15:00, SAT 10:00-15:00, SUN 10:00-15:00."
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I got it, I don't need the token, please. Just the merchant id.
0 Likes 0 ·
af-data avatar image
af-data answered David Marginian Deactivated edited

See above, I was not getting a 503 error (I was running the calls in the allowed time frame). What is happening is that the call is not returning a url.

See line 10:

'exportUrls': {'elements': [] }

Inside the list should be a (or a series) of urls where I can download the records.



  1. { 'id': 'VJS1YC61KWF1W',
  2. 'type': 'PAYMENTS',
  3. 'status': 'DONE',
  4. 'percentComplete': 100,
  5. 'availableUntil': 1624711390000,
  6. 'startTime': 1624511000,
  7. 'endTime': 1624597000,
  8. 'createdTime': 1624624981000,
  9. 'modifiedTime': 1624624990000,
  10. 'exportUrls': { 'elements': []},
  11. 'merchantRef': { 'id': 'NZ492DDYP2AY1'},
  12. 'retryCount': 0}
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I checked our server logs, and the only export request over the last few days for that merchant is returning a 503. I am assuming that is why the subsequent call it's returning no files.

0 Likes 0 ·

Welcome to the
Clover Developer Community