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

Error: TypeError - Cannot read properties of undefined (reading 'toString') #341

Closed
sanjai0py opened this issue Feb 13, 2024 · 1 comment

Comments

@sanjai0py
Copy link

sanjai0py commented Feb 13, 2024

I tried converting HAR with Headers and Query Parameters to Powershell, which worked as expected. But when provided with body it throws this error.

TypeError: Cannot read properties of undefined (reading 'toString')
    at escapeString (escape.js?056a:43:1)
    at convert (common.js?aa75:formatted:54:35)
    at eval (httpsnippet.js?8e8e:238:67)
    at Array.map (<anonymous>)
    at HTTPSnippet.convert (httpsnippet.js?8e8e:238:1)
    at CodeView (index.js?c905:33:43)
    at renderWithHooks (react-dom.development.js?3c4a:16305:1)
    at updateFunctionComponent (react-dom.development.js?3c4a:19588:1)
    at beginWork (react-dom.development.js?3c4a:21601:1)
    at beginWork$1 (react-dom.development.js?3c4a:27426:1)
    at performUnitOfWork (react-dom.development.js?3c4a:26557:1)
    at workLoopSync (react-dom.development.js?3c4a:26466:1)
    at renderRootSync (react-dom.development.js?3c4a:26434:1)
    at performSyncWorkOnRoot (react-dom.development.js?3c4a:26085:1)
    at flushSyncCallbacks (react-dom.development.js?3c4a:12042:1)
    at eval (react-dom.development.js?3c4a:25651:1)

The HAR request

{
    "method": "POST",
    "url": "https://example.com?id=1",
    "httpVersion": "HTTP/1.1",
    "cookies": [],
    "headers": [
        {
            "name": "Authorization",
            "value": "sadasdsdsaadasdsads"
        }
    ],
    "queryString": [
        {
            "name": "id",
            "value": "1"
        }
    ],
    "postData": {
        "mimeType": "application/json",
        "text": "{\n  \"name\": \"somename\"\n}",
        "jsonObj": {
            "name": "somename"
        }
    },
    "headersSize": 0,
    "bodySize": 0
}
@KirkMunroSagent
Copy link

Did you happen to try the same, but without newline characters in the body? I wonder if it has to do with the escape character used for newlines in PowerShell strings being a backtick instead of a backslash. Removing the newlines to see if that works would be a worthwhile test.

Another test worth running would be doubly-escaping the newlines (i.e. "text": "{\\n \"name\": \"somename\"\\n}",, since you're not trying to escape the n characters in the json property value, but in the converted string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants