[SOLVED] Need Help With Raw Data Export

Hi, I’m having some trouble trying to use the Raw Data Export feature.

I’m not really good with curl and html requests, so I’m probably doing something wrong…
I’m using cURL for windows and I’ve written this command in the cmd line:

curl -g^
–user “UNITY_PROJECT_ID”:“API-KEY”^
–request POST^
–header “Content-Type: application/json”^
–data ‘{“startDate”:“2016-05-20”,“endDate”:“2016-06-12”,“format”:“tsv”,“dataset”:“custom”}’^
https://analytics.cloud.unity3d.com/api/v2/projects/UNITY_PROJECT_ID/rawdataexports

Where UNITY_PROJECT_ID and API-KEY are the values I got from the analytics dashboard.

I get a html page titled “We’re sorry, but something went wrong (500)” as response.

Am I doing something wrong?

Thanks for your help!

@Macellomatik ,

The url you listed as part of your script - it should be Unity Cloud

Using the api-key instead of the project id could cause this 500 error, can you check whether you still have the issue when you use the project id in the url?

Thanks for the reply,
I’m sorry but I did a mistake while writing the post, I was using the UNITY_PROJECT_ID already.
I’m editing the post to avoid confusion.

Hi @Macellomatik ,

We’re working on getting a more detailed error message instead of just a 500 error.
Regarding your curl request, can you try removing the “-g” and also the new lines.
So it should look like this:

curl --user UNITY_PROJECT_ID:API-KEY --request POST --header "Content-Type: application/json" --data '{"startDate":"2016-05-20","endDate":"2016-06-12","format":"tsv","dataset":"custom"}' https://analytics.cloud.unity3d.com/api/v2/projects/UNITY_PROJECT_ID/rawdataexports

Hi, and thank you for the help,

I tried using the command that way but I got the same error.

The exact command I used is (except for the *** obviously)

curl --user "0***5:1***4" --request POST --header "Content-Type: application/json" --data '{"startDate":"2016-05-20","endDate":"2016-06-12","format":"tsv","dataset":"custom"}' https://analytics.cloud.unity3d.com/api/v2/projects/0***5/rawdataexports

Hi @Macellomatik

Our logs are showing a problem with the JSON data that you are sending. For some reason the received JSON blob does not have the expected double quotes around the keys and values.

I tried copy pasting the command you pasted in your previous reply (replacing just the credentials) and it worked fine. However, if I strip out the double quotes from the JSON keys and values then I will get the same 500 error. Is it possible something on your end is stripping out the double quotes?

Here’s example of the correct JSON with double quotes around the keys and values:

{"startDate":"2016-05-20","endDate":"2016-06-12","format":"tsv","dataset":"custom"}

@Macellomatik We plan on supporting a webform to create requests, that would simplify the creation process.

Hi everybody, and thanks for all the help.

I’ve been able to find the issue with the Json Data: in Windows the single quotes are not allowed, and must be substituted with double quotes. Also the inner double quotes have to be escaped.

The command I used to make it work was

curl --user "UNITY_PROJECT_ID:API_KEY" --request POST --header "Content-Type: application/json" --data "{\"startDate\":\"2016-06-1\",\"endDate\":\"2016-06-21\",\"format\":\"tsv\",\"dataset\":\"custom\"}" https://analytics.cloud.unity3d.com/api/v2/projects/UNITY_PROJECT_ID/rawdataexports

Hope this can help others, and thanks again!

1 Like