{"record":{"id":"d97176ed986b7ca6","repo":"apify/crawlee","slug":"request-with-get-method-cannot-have-a-payload","errorCode":null,"errorMessage":"Request with GET method cannot have a payload.","messagePattern":"Request with GET method cannot have a payload\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/request.ts","lineNumber":217,"sourceCode":"            keepUrlFragment = false,\n            useExtendedUniqueKey = false,\n            alwaysEnqueue = false,\n            skipNavigation,\n            enqueueStrategy,\n            crawlDepth,\n        } = options as RequestOptions & {\n            loadedUrl?: string;\n            retryCount?: number;\n            sessionId?: string;\n            errorMessages?: string[];\n            handledAt?: string | Date;\n        };\n\n        let { method = 'GET' } = options;\n\n        method = method.toUpperCase() as AllowedHttpMethods;\n\n        if (method === 'GET' && payload) throw new Error('Request with GET method cannot have a payload.');\n\n        if (uniqueKey && alwaysEnqueue) {\n            throw new Error('`alwaysEnqueue` cannot be used together with a custom `uniqueKey`.');\n        }\n\n        this.id = id;\n        this.url = url;\n        this.loadedUrl = loadedUrl;\n        this.uniqueKey =\n            uniqueKey ||\n            CrawleeRequest.computeUniqueKey({\n                url,\n                method,\n                payload,\n                keepUrlFragment,\n                useExtendedUniqueKey,\n                alwaysEnqueue,\n            });","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/request.ts#L199-L235","documentation":"A GET request cannot carry a payload/body, so the Request constructor rejects the combination of method GET (explicit or the default) with a non-empty payload. HTTP semantics simply do not define a body for GET.","triggerScenarios":"new Request({ url, payload, method: 'GET' }) or new Request({ url, payload }) omitting method (defaults to GET).","commonSituations":"Sending data via GET that should be a POST; forgetting that method defaults to GET when only payload is provided; building requests dynamically where method and payload drift out of sync.","solutions":["Change the method to POST (or PUT/PATCH) when sending a payload","Move the data into the URL query string if GET is required","Assert/validate that payload is undefined whenever method is GET"],"exampleFix":"// before\nconst request = new Request({ url: 'https://example.com/search', payload: { q: 'x' } });\n// after\nconst request = new Request({ url: 'https://example.com/search', method: 'POST', payload: { q: 'x' } });","handlingStrategy":"validation","validationCode":"if ((method?.toUpperCase() ?? 'GET') === 'GET' && payload) throw new Error('GET cannot have a payload');","typeGuard":null,"tryCatchPattern":"try {\n  return new Request(opts);\n} catch (err) {\n  if (err.message.includes('GET method cannot have a payload')) {\n    return new Request({ ...opts, method: 'POST' });\n  }\n  throw err;\n}","preventionTips":["Remember method defaults to GET — set it explicitly when sending a body","Validate method/payload pairing in request-building helpers","Use query params for GET data instead of a body"],"tags":["http","request","validation"],"backgroundTag":"get-request-with-body","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}