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

postUrl example #352

Closed
mikylucky opened this issue May 19, 2020 · 6 comments
Closed

postUrl example #352

mikylucky opened this issue May 19, 2020 · 6 comments

Comments

@mikylucky
Copy link

mikylucky commented May 19, 2020

Hi, can you provide an example on how to populate the postData object in a postUrl call?

A fake postData object would be nice to see

@pichillilorenzo
Copy link
Owner

You need to import the import 'dart:convert'; library and encode your POST body string into a Uint8List data.

To do that you can use, for example, the utf8.encode() method.

Here is an example:

onWebViewCreated: (InAppWebViewController controller) {
  var data = "firstname=Foo&lastname=Bar";
  controller.postUrl(url: "http://192.168.1.123:8082/test-ajax-post", postData: utf8.encode(data));
},

@simkosal
Copy link

onWebViewCreated: (InAppWebViewController controller) {
var data = "firstname=Foo&lastname=Bar&hash=8ZaZJ3Cc5n89LoLBBTwnpJ3YuQSulYnekJtCSO7bfE+9hMGtHaj";
controller.postUrl(url: "http://www.example.com", postData: utf8.encode(data));
},

I got nothing in webview. I know that because of my hash key is have plus (+) symbol that make webview can't load.
Question: How can i postData with hash?

@RemmoYu
Copy link

RemmoYu commented Sep 28, 2020

@masiJR Uri.encodeComponent(yourString)

@simkosal
Copy link

@RemmoYu Thank you bro.

@paraslamsong
Copy link

@pichillilorenzo
How can we post formdata in initial request?

@Sumit258000
Copy link

@RemmoYu Can you please explain your answer I am facing same problem when I am sending Form Data + symbol is replaced by space how can I avoid that?

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

6 participants