Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Export is not working #175

Closed
mehaase opened this issue Mar 31, 2022 · 4 comments
Closed

JSON Export is not working #175

mehaase opened this issue Mar 31, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@mehaase
Copy link
Contributor

mehaase commented Mar 31, 2022

It is exporting a JSON object, but it is embedded inside of an HTML document. It is supposed to be a stand-alone JSON document.

@mehaase mehaase self-assigned this Mar 31, 2022
@mehaase
Copy link
Contributor Author

mehaase commented Mar 31, 2022

Attaching a screenshot… (this is using the AA20-302A.pdf sample report in TRAM's own test data)

screenshot of bug

@mehaase mehaase added the bug Something isn't working label Mar 31, 2022
@nanda-rani
Copy link

Hi @mehaase , Have you resolved json reading issue?
I'm also facing the same. Please let me know if there is anyway to read the exported JSON file.

@mehaase
Copy link
Contributor Author

mehaase commented May 5, 2022

Investigating this issue today. From the command line I can download the json file just fine, e.g.,

http -v "localhost:8000/api/report-export/9/?type=json" "Cookie: sessionid=(REDACTED)"  > report.json

It seems this issue is triggered only in the browser, because the browser sends the header Accept: text/html whereas the command line (HTTPie) sends Accept: application/json. I think DRF's Content Negotiation is getting in the way.

mehaase added a commit that referenced this issue May 5, 2022
JSON exports were being rendered through an HTML template due to
content negotiation in the browser (e.g. Accept:text/html). This commit
forces the renderer to use JSON regardless of content negotiation and
also cleans up the json and docx export code.
mehaase added a commit that referenced this issue May 19, 2022
JSON exports were being rendered through an HTML template due to
content negotiation in the browser (e.g. Accept:text/html). This commit
forces the renderer to use JSON regardless of content negotiation and
also cleans up the json and docx export code.
mehaase added a commit that referenced this issue May 19, 2022
Based on Nick's feedback, reverted to using two ViewSets, moved the
docx code into a custom renderer, and use Django's built in format
parameter instead of type. This makes for a much cleaner PR.
mehaase added a commit that referenced this issue May 20, 2022
JSON exports were being rendered through an HTML template due to
content negotiation in the browser (e.g. Accept:text/html). This commit
forces the renderer to use JSON regardless of content negotiation and
also cleans up the json and docx export code.
mehaase added a commit that referenced this issue May 20, 2022
Based on Nick's feedback, reverted to using two ViewSets, moved the
docx code into a custom renderer, and use Django's built in format
parameter instead of type. This makes for a much cleaner PR.
mehaase added a commit that referenced this issue May 20, 2022
Based on Nick's feedback, reverted to using two ViewSets, moved the
docx code into a custom renderer, and use Django's built in format
parameter instead of type. This makes for a much cleaner PR.
mehaase added a commit that referenced this issue May 20, 2022
Based on Nick's feedback, reverted to using two ViewSets, moved the
docx code into a custom renderer, and use Django's built in format
parameter instead of type. This makes for a much cleaner PR.
mehaase added a commit that referenced this issue Jun 4, 2022
…ix-json-export

Fix JSON export for reports (#175)
@mehaase
Copy link
Contributor Author

mehaase commented Jun 15, 2022

This is fixed in #180 and released in v1.2.0.

@mehaase mehaase closed this as completed Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants