question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FormData not being sent in Request

See original GitHub issue

My goal is to send an image to my backend.

What I’m doing to send the request

const data = new FormData();
data.append('file', {
    name: 'some_random_name.jpg',
    type: 'image/jpeg',
   path: getURI()
});

await fetchSSL('/api/files', {
    method: 'PUT',
    headers: {
        'Accept': 'application/json', 
        'User-Agent': userAgent
    },
    disableAllSecurity: true, // for easier testing
    pkPinning: false,  // for easier testing
    sslPinning: {
      certs: []  // for easier testing
    },
    body: {
        formData: data
    }
})

the form data being passed, can be seen in the screenshot Bildschirmfoto 2021-03-03 um 13 00 25

I intercepted the request before it hit my servers and it appears the form data has not been appended (this looks different when not using this library): Bildschirmfoto 2021-03-04 um 08 44 45

The library itself also does not give me any notice about something going wrong. Of course, I get an error in the response from my server, but i would expected to get some kind of error.

I have tried to use the example from your readme. So the multi-part/form content type header has already been omitted. I also see the form Data being used when i added some logging statements to your native coe I have seen in other issues that you recommended using base64, but when i have both path and data, the data seems to not have any effect, and only using data caused an error somehow like (https://github.com/MaxToyberman/react-native-ssl-pinning/issues/38)

I would greatly appreciate your help, since your library seems to be the only way to provide ssl pinning while also having a feedback to the react native js code to show some nice alerts if something goes wrong. However, not being able to upload images makes this unusable, since this is a hard requirement for us.

Context: RN Version: 0.63.3 RN-SSL-Pinning Version: 1.5.4 OS: iOS (have not validated Android) Normal json body payloads work fine When ditching this library and using default react native fetch method, it also works fine

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BerniWittmanncommented, Apr 17, 2022

@Nageshwar1213 No sadly not. We have essentially put the effort to do ssl pinning on hold until this is issue is resolved…

0reactions
Nageshwar1213commented, Apr 17, 2022

HI @BerniWittmann did u got the solution for this issue .please let me know I am struggling to resolve this issue .

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Cannot send formdata using post request
Cannot send formdata using post request ... I'm trying to send a form data with a file using POST request in Angular 4....
Read more >
FormData is not being send · Issue #213 · capacitor- ...
Describe the bug I'm trying to do a post with a img file in a FormData and the request sends nothing Steps to...
Read more >
Having trouble sending an HTTP POST request with form- ...
I'm trying to send an HTTP POST request with form-data from an Angular app to a Cache backend, but my request fails with...
Read more >
File Upload not working, additional post data not being sent
I am trying to post some additional data along with a file upload, and I am basically trying to extend the Basic Plus...
Read more >
Request.formData() - Web APIs - MDN Web Docs
The formData() method of the Request interface reads the request body and returns it as a promise that resolves with a FormData object....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found