René's URL Explorer Experiment


Title: JSONDecodeError when getting/polling a 202/Conversion in progress response · Issue #21 · ConvertAPI/convertapi-library-python · GitHub

Open Graph Title: JSONDecodeError when getting/polling a 202/Conversion in progress response · Issue #21 · ConvertAPI/convertapi-library-python

X Title: JSONDecodeError when getting/polling a 202/Conversion in progress response · Issue #21 · ConvertAPI/convertapi-library-python

Description: I'm using the asynchronous conversion mode and I'm using the convertpi.client.get method to poll the conversion result. I'm polling the results only after receiving the webhook confirmation, understanding that the conversion process woul...

Open Graph Description: I'm using the asynchronous conversion mode and I'm using the convertpi.client.get method to poll the conversion result. I'm polling the results only after receiving the webhook confirmation, unders...

X Description: I'm using the asynchronous conversion mode and I'm using the convertpi.client.get method to poll the conversion result. I'm polling the results only after receiving the webhook confirma...

Opengraph URL: https://github.com/ConvertAPI/convertapi-library-python/issues/21

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSONDecodeError when getting/polling a 202/Conversion in progress response","articleBody":"I'm using the [asynchronous conversion mode](https://www.convertapi.com/doc/async) and I'm using the [convertpi.client.get](https://github.com/ConvertAPI/convertapi-python/blob/392a48e637fa13f3aeb3a1f807b50f566b25c82f/convertapi/client.py#L8) method to poll the conversion result.\r\n\r\nI'm polling the results only after receiving the webhook confirmation, understanding that the conversion process would have been successful in this case.\r\n\r\nFor some reason, when polling results from the API **after the webhook confirmation**, I'm getting a response different than 200 OK. These are the possible status codes:\r\n\r\n* 200 Conversion is successful. Response is a conversion result.\r\n* 202 Conversion in progress.\r\n* 404 JobId is invalid or response is expired.\r\n* 503 No concurrent poll requests are allowed..\r\n* 5XX Conversion error. Response is an error message.\r\n\r\nI mostly get 200 OK responses when polling after the confirmation, but there are cases where I get a 202 Accepted with blank content. I suppose I'm hitting the API too fast and there is some internal propagation still ongoing, but that is not the point anyway, I could simply retry it and it will work.\r\n\r\nThe problem is that, since the response content is a blank string, and since the get method uses the [handle_response method](https://github.com/ConvertAPI/convertapi-python/blob/392a48e637fa13f3aeb3a1f807b50f566b25c82f/convertapi/client.py#L44) to convert the response to JSON or raise an exception, I'm hitting the unexpected exception _json.decoder.JSONDecodeError_.\r\n\r\nThe other error responses would _raise_for_status_ and fail legitimely. The only problem is with the 202 response, that is a successful status (so it is not raised), but can't be returned as json. I wrote a small wrapper to solve this at my side:\r\n\r\n```python\r\ndef poll_retrieve(job_id):\r\n    convertapi.api_secret = settings.CONVERT_API_SECRET\r\n    response = requests.get(\r\n        convertapi.client.url(f\"job/{job_id}\"),\r\n        headers=convertapi.client.headers(),\r\n        timeout=convertapi.timeout or None,\r\n    )\r\n    response.raise_for_status()\r\n    if response.status_code == 202:\r\n        raise ConversionInProgressError\r\n    return response.json()\r\n```\r\n\r\nI could write a pull request, but I want to discuss with you the best approach first: is a new exception (like this ConversionInProgressError) a good idea? Or do you think returning a blank list would work better?","author":{"url":"https://github.com/michelts","@type":"Person","name":"michelts"},"datePublished":"2021-06-01T14:27:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/21/convertapi-library-python/issues/21"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b2a1b771-f213-14fd-3f79-e44e1fa71ded
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9CD6:2F1E1C:D7EE6F:131823B:697B8161
html-safe-nonceaa7ac37b13801cef0bea88428774100eb4f2ac0335b4a6517f629ca44ac8dfa8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0Q2OjJGMUUxQzpEN0VFNkY6MTMxODIzQjo2OTdCODE2MSIsInZpc2l0b3JfaWQiOiIzOTY1MTc2NTU4OTA5MDk2Mjg5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac11accc0f3b2776212d68987ac2550fb8b2beb3fad4c3e840daacb995d2240b6a
hovercard-subject-tagissue:908353135
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ConvertAPI/convertapi-library-python/21/issue_layout
twitter:imagehttps://opengraph.githubassets.com/131d0d385bb19fa0973def357fe82c2e3a520b12216ed5ddbd05b35a3e6f3392/ConvertAPI/convertapi-library-python/issues/21
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/131d0d385bb19fa0973def357fe82c2e3a520b12216ed5ddbd05b35a3e6f3392/ConvertAPI/convertapi-library-python/issues/21
og:image:altI'm using the asynchronous conversion mode and I'm using the convertpi.client.get method to poll the conversion result. I'm polling the results only after receiving the webhook confirmation, unders...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemichelts
hostnamegithub.com
expected-hostnamegithub.com
None26ef504c9f5eb2ac26b53c0437f934bbe4c0464979d7386917bd32d9fe70fc7a
turbo-cache-controlno-preview
go-importgithub.com/ConvertAPI/convertapi-library-python git https://github.com/ConvertAPI/convertapi-library-python.git
octolytics-dimension-user_id37071453
octolytics-dimension-user_loginConvertAPI
octolytics-dimension-repository_id132747126
octolytics-dimension-repository_nwoConvertAPI/convertapi-library-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id132747126
octolytics-dimension-repository_network_root_nwoConvertAPI/convertapi-library-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecea9b2b812b4d84ebc94c8a8bd97e2e99a2c0b48
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues/21#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FConvertAPI%2Fconvertapi-library-python%2Fissues%2F21
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FConvertAPI%2Fconvertapi-library-python%2Fissues%2F21
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=ConvertAPI%2Fconvertapi-library-python
Reloadhttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues/21
Reloadhttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues/21
Reloadhttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues/21
ConvertAPI https://patch-diff.githubusercontent.com/ConvertAPI
convertapi-library-pythonhttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FConvertAPI%2Fconvertapi-library-python
Fork 22 https://patch-diff.githubusercontent.com/login?return_to=%2FConvertAPI%2Fconvertapi-library-python
Star 87 https://patch-diff.githubusercontent.com/login?return_to=%2FConvertAPI%2Fconvertapi-library-python
Code https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python
Issues 3 https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues
Pull requests 1 https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/pulls
Actions https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/actions
Projects 0 https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/projects
Security 0 https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/security
Insights https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/pulse
Code https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python
Issues https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues
Pull requests https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/pulls
Actions https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/actions
Projects https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/projects
Security https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/security
Insights https://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/ConvertAPI/convertapi-library-python/issues/21
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/ConvertAPI/convertapi-library-python/issues/21
JSONDecodeError when getting/polling a 202/Conversion in progress responsehttps://patch-diff.githubusercontent.com/ConvertAPI/convertapi-library-python/issues/21#top
https://github.com/michelts
https://github.com/michelts
micheltshttps://github.com/michelts
on Jun 1, 2021https://github.com/ConvertAPI/convertapi-library-python/issues/21#issue-908353135
asynchronous conversion modehttps://www.convertapi.com/doc/async
convertpi.client.gethttps://github.com/ConvertAPI/convertapi-python/blob/392a48e637fa13f3aeb3a1f807b50f566b25c82f/convertapi/client.py#L8
handle_response methodhttps://github.com/ConvertAPI/convertapi-python/blob/392a48e637fa13f3aeb3a1f807b50f566b25c82f/convertapi/client.py#L44
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.