Forum Discussion

noob_Vibes's avatar
noob_Vibes
New Contributor
28 days ago

Long shot question from noob

I work a manual job for a farily sizeable company in a distant land. We have a lot of staff and a lot of tasks, part of my job is to match staff to tasks. I'm also a novice developer and write little web apps for fun. My latest project is a webpage that myself and my colleagues can use to help assign staff to tasks; everyone loves it because it saves us all several hours each week. 

The company uses Sling employee scheduling software to handle the rostering stuff, I export the data from Sling to use on my webpage and I'm trying to automate this instead of having to download a csv and upload it to my server. 

Sling's API documentation lead me to Swagger, which led me here. Sling keep telling me they don't provide API support so maybe someone here can help?

I want to export a csv from the API and to do this I provide 3 parameters; the format, authorization and data to export. Format and authorization is simple and I've no trouble accessing other endpoints, but I have no idea what to provide in the data field for the export; I've tried iso format dates and various other stuff to no avail. 

So for example a curl request would look like: 

curl -X POST "https://api.getsling.com/v1/export" -H  "accept: application/json" -H  "Content-Type: multipart/form-data" -F "Authorization=<my authorization code goes here>" -F "format=csv" -F "data=??????????????"

but what data is expected? 

Another thing that's maybe an issue is that the response is always "Oops an unexpected error has occurred" instead of a 400 or a 405; but I have no trouble manually exporting a csv file from the Sling website. 

 

Any ideas?

2 Replies

  • Parker's avatar
    Parker
    New Contributor

    You are using multipart/form-data in your curl request, which is typically used for file uploads. If you're sending a simple data payload, application/json might be more appropriate unless the API specifically requires multipart.

    • noob_Vibes's avatar
      noob_Vibes
      New Contributor

      That curl request is generated by the API as an example request when you enter the parameters into the form fields, so it should be correct. I just don't know how to format the 'data' field, or what data to send.