i want to make Post Request Using formBody parameters using rn-fetch-blob. please tell me how to do it?
Asked
Active
Viewed 1,560 times
1 Answers
0
This is an example of formdata
that you want.
Multipart/form-data example
RNFetchBlob.fetch('POST', 'http://www.example.com/upload-form', {
Authorization : "Bearer access-token",
otherHeader : "foo",
'Content-Type' : 'multipart/form-data',
}, [
// element with property `filename` will be transformed into `file` in form data
{ name : 'avatar', filename : 'avatar.png', data: binaryDataInBase64},
// custom content type
{ name : 'avatar-png', filename : 'avatar-png.png', type:'image/png', data: binaryDataInBase64},
// part file from storage
{ name : 'avatar-foo', filename : 'avatar-foo.png', type:'image/foo', data: RNFetchBlob.wrap(path_to_a_file)},
// elements without property `filename` will be sent as plain text
{ name : 'name', data : 'user'},
{ name : 'info', data : JSON.stringify({
mail : 'example@example.com',
tel : '12345678'
})},
]).then((resp) => {
// ...
}).catch((err) => {
// ...
})

hong developer
- 13,291
- 4
- 38
- 68
-
why any https url is not working in react native. it is working fine in ios but after ssl certification any webservices is not working in android. even images not workin with https url. please i need solution – Prajapati Jigar Aug 08 '19 at 09:18
-
@PrajapatiJigar It depends on your React-native version. If the React-native version is installed at 0.46 or later, this problem could be solved. – hong developer Aug 08 '19 at 09:20
-
0.57.1 version i am using – Prajapati Jigar Aug 08 '19 at 09:23
-
this is not the solution – Prajapati Jigar Aug 08 '19 at 09:23
-
What is the version of your Android device? – hong developer Aug 08 '19 at 09:24
-
Https is supported starting with Android 9. – hong developer Aug 08 '19 at 09:42
-
please i am working for 10 days but still did not get the solution – Prajapati Jigar Aug 08 '19 at 10:05
-
Is the simulator Android version 9 or higher? – hong developer Aug 08 '19 at 13:37
-
i have chcked both in android 9 and marshmallow but it is not working on any one – Prajapati Jigar Aug 09 '19 at 05:30
-
Please refer https://gist.github.com/seriiix/093289bb28747e26301432a5fba6b060 , https://github.com/facebook/react-native/issues/23151 – hong developer Aug 09 '19 at 05:31
-
@PrajapatiJigar First of all, I can't see your Android files. And your questions differ in scope from the questions in the postings. If my answer helped the question,I think it would be advisable to you choose an my answer and post a new question after the question has been closed. – hong developer Aug 09 '19 at 08:00