been working on this one about a week already. So i'm using React Native's fetch method to access our API. Using the GET method works, means that i was able to get data in our API. The problem now is the POST and PUT methods, when using PUT to send data, the value passed is always a null value. I tried using console.log in chrome browser, the response is 200, so means its ok and it was able to talk to the API, the only this is that the value is sent is always a null value. Note also that manually updating the data using Postman works, only doesnt work when API is called from React Native. help will really help me continue my development since i'm really stuck with this one. Thanks a lot guys
See this file to see some code snippets
I also had this issue before and what I found out about the problem is:
Our server does not prepare api for "utf-8", and android avd sent requests with "charset=utf-8". So it will cause one of the platform showing error because the request charset is not same.
The issue is here and they still not fix it: https://github.com/facebook/react-native/issues/8237
Check the Content-type in the headers of your POST and PUT requests. Set it to application/json if your API takes parameters in JSON format.
Related
Im not quite sure whether the problem is with my android program or its a some kind of limitation in the web server api. Im using futurerequest to get the data from xively with api key and feed id, and parsing the data in json format, then storing it in my db. The connection establishes just fine and im able to connect and get the data from the server. This is done through an asynctask and the request frequency is 1 min.
The issue im facing is that when i update the data in the server through web browser, the response on my program is not updated. It keeps getting the old data. When debugging i can clearly see that everything is working as intended, and i can see that the json response object i get from the server is working, however, the data is not fresh. I found out that by changing the api key manually makes the program get the newest data. Also by clearing the cache and data results in fetching the new data from the server. As you you know, i cant ask the user to clear his cache and data everytime to get the latest update.
How do i go about this issue? What might be the reason behind this problem? Thanks in advance!
Edit: Clearing the cache alone does not help. Also, using the phone instead of the emulator doesnt help either.
Im using volley library to handle the request/network traffic
Wanted to updated the solution that i found. This link helped me find the solution. Apparently, there is some caching involved by volley. By using the method
request.setShouldCache(false);
i was able to get the lasted updates from the server at all times.
However, when i tried to get the cache with the code below, before setting it to false, to see whats in the cache it was empty. entry would always be null. if someone know why and could explain i would be grateful :)
Entry entry = queue.getCache().get(url);
if(entry!=null){
String data = new String(entry.data, "UTF-8");
// process data
}
I have an expressJS server running. I am POSTING multipart form-data to the server, and parsing this with GridForm (which again, correct me if I am wrong, is an extension of FormidableJS). This seems to work fine when posting from a web-form, or Postman etc., however, when I try to post from my Android app or IOS app, there is a strange issue. Sometimes it works fine, and then, even though I do no changes in the app code, no fields are parsed. The files are however allways parsed, so it is clear that the POST actually comes through. Anyone have any ideas of what this problem can be?
I am trying to send an OPTIONS request from my android application to my Windows 2008 Server webservice (which is a .net webservice). I am using SSL, and am having difficulty getting this to work. I really need to know exactly what my headers should look like. I know I don't send the body, I just need to know what to send. I really need an example not a link to someone just talking about some things.
I found the answer. It was working. I just wasnt looking in the right place for my response. I was looking at the final response that I get from my Soapbuilder class, and I am stripping out the headers before returning. I is actually giving the right options headers back.
I am just beginning to look at using json and a rest client setup to connect with a rest server. Is there a server that can be accessed just so I can try my code and see what is returned.
Blizzard just opened up their API for JSON using HTTP. So it's probably really close to what you're looking for, and it's got potentially LOT of interesting data to play with, even if you don't play the game.
http://blizzard.github.com/api-wow-docs/
Note, you may be limited how much you can use it. But for a simple app and testing, this should not be a problem.
I only want to send an html form by post method to a https resource from an Android activity.
I have (only for development and testing) an Lighttpd server with it own certificate to make handshaking, so there MUST happen authentication at least from server (client authentication is optional but desirable).
I have seen, lots of forums with different ways to make it, but I am a little confused, I do not know which could be the correct way to make it.
Please show me a chunk of code.
Thank you very very much.
Try out this tutorial, it shows GET, POST and Multipart POST request on the android platform
http://www.softwarepassion.com/android-series-get-post-and-multipart-post-requests/
I wrote some code to submit an HTML form to a server over https, which can be found in this answer. The version in the answer uses an HttpsUrlConnection, and the version in the question uses HttpClient. I could never quite get the right result from the server with the HttpClient version, but either approach should work in theory.