question

pceccon avatar image
pceccon asked

Post error : Invalid JSON primitive: ReportName.,API post returning Invalid JSON primitive: ReportName

I'trying to get some reports urls trough Python endpoint API but I keep getting this message

> b'{"code":400,"status":"BadRequest","error":"InvalidRequest","errorCode":1071,"errorMessage":"Invalid JSON in request","errorHash":"7a38e6552fcba244116c028ea9ba90bb","errorDetails":{"ValidationError":["Invalid JSON primitive: ReportName."]}}'

However, the report name comes from a valid report (as shown in attachment) and according to the docs, `ReportName` is a valid and required field.

This is the piece of code that I'm using:

data = dict()
data["ReportName"] = report_name
data["Year"] = date.year
data["Month"] = date.month
data["Day"] = date.day

header = dict()
header["Content-Type"] = "application/json"
header["X-SecretKey"] = self.config.get("playfab", "token")

try:
    r = requests.post(self.config.get("playfab", "endpoint"), data=data, headers=header)
    r = r.json()
    # OTHER STUFF
    else:
        self.info.exception("Empty response from PlayFab endpoint.")

except Exception as exc:
    self.logger.exception("Error accessing PlayFab endpoint.")

`data` look like this:

<class 'dict'>: {'ReportName': 'Thirty Day Retention Report', 'Year': 2018, 'Month': 11, 'Day': 26}

I can't figure it out what is wrong.

,

I'trying to get some reports urls trough Python endpoint API but I keep getting this message

> b'{"code":400,"status":"BadRequest","error":"InvalidRequest","errorCode":1071,"errorMessage":"Invalid JSON in request","errorHash":"7a38e6552fcba244116c028ea9ba90bb","errorDetails":{"ValidationError":["Invalid JSON primitive: ReportName."]}}'

However, the report name comes from a valid report (as shown in attachment) and according to the docs, `ReportName` is a valid and required field.

This is the piece of code that I'm using:

data = dict()
data["ReportName"] = report_name
data["Year"] = date.year
data["Month"] = date.month
data["Day"] = date.day

header = dict()
header["Content-Type"] = "application/json"
header["X-SecretKey"] = self.config.get("playfab", "token")

try:
    r = requests.post(self.config.get("playfab", "endpoint"), data=data, headers=header)
    r = r.json()
    # OTHER STUFF
    else:
        self.info.exception("Empty response from PlayFab endpoint.")

except Exception as exc:
    self.logger.exception("Error accessing PlayFab endpoint.")

`data` look like this:

<class 'dict'>: {'ReportName': 'Thirty Day Retention Report', 'Year': 2018, 'Month': 11, 'Day': 26}

I can't figure it out what is wrong.

analyticsdocumentation
1 comment
10 |1200

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

Seth Du avatar image Seth Du ♦ commented ·

This issue can be caused by the blank spaces in your ReportName. Would you please delete them in both sides and give another try? if this error keeps showing up, we will try to reproduce your issue. Still we suggest you should make use of our Python SDK rather than crafting your own HTTP calls.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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