NativeScript + http PROPFIND method in android : is it possible? - nativescript

I'm working on a contacts app on NativeScript, so I need to connect to a webdav server with PROPFIND method.
I'm working on Android.
Eveything works on a node project, but in NativeScript I can't manage to get an answer from my PROPFIND request.
I tried with 3 different methods, each of them being OK in node and KO in nativescript. UPDATE : I also tried on React Native, and it worked like a charm.
My results in NativeScript :
core HTTP from nativescript :
"HTTP erreur Error: java.net.ProtocolException: Expected one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH] but was PROPFIND"
axiox :
"Error: Request failed with status code null"
Fetch :
"TypeError: Network request failed"
If I change the method (GET or POST instead of PROPFIND), I receive "normal" http errors related to the face that it's not the good method.
--> could it be a dead end with Native Script ? I hope there is a way to bypass this and use webdav methods in Native Script !
Thanks++.

Related

React Native form data request failed with no multipart boundary was found

I'm struggled with react native file upload using Axios form data. I set the content type as multipart/form-data. below is my request parts.
form-data body content
{"_parts":[["profileImage",{"name":"rn_image_picker_lib_temp_51ee6068-2b4b-4baf-a6c3-44b14b0b5b9b.jpg","type":"image/jpeg","uri":"file:///data/user/0/com.sentura.xchange/cache/rn_image_picker_lib_temp_51ee6068-2b4b-4baf-a6c3-44b14b0b5b9b.jpg"}],["email","xx#gmail.com"],["firstName","vv"],["lastName","ss"],["address","sdf"],["postalCode","2323"],["mobileNumber","0796677653"],["country","Anguilla"],["countryCode","+1264"]]}"
request headers
"headers":{
"Accept":"application/json",
"Authorization":"Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ2aWR1OTk2QGdtYWlsLmNvbSIsImV4cCI6MTY0NTk1ODYzNywiaWF0IjoxNjQ1OTU3NzM3fQ.GZMQFYGU4veH4xZ9ki2afWmtbGCKhOK5JruWLRX75nisVXXX9JmQYf31ns_ALVr9N1-RgcpMabolgHQSMZ7KIw",
"Content-Type":"multipart/form-data"
}
but from the spring boot side, it gives the below error. but this work in postman.
org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
Hope your support to resolve this. thanks!
This works for me:
"Content-Type" : 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
Actually the issue happened with my react native version. i don't know what is the correct way to achieve it with newest react native versions. i worked with react native 0.67. unfortunately, it's broken.
I added the same code base to react native 0.64 and it worked well as i expected. didn't do any code change to axios or any other.

Provisional headers are shown in laravel + ionic

I'am using laravel + ionic.
my ionic is run on localhost:8100.
and my laravel is running on myDomain/get/posts/comment.
Iam using vagrant box for laravel.
my problem is when I access the myDomain/get/posts/comment throw browser, I got the response.
bu when I call this URL through ionic, response status code is 200.
but showind Provisional headers are shown.
Please help me to solve this.
I searched on internet for solution, but couldn't solve.

Cordova App 8.1 Caching HTTP request

I'm working on an app using Visual Studio 2015 Cordova tools on Windows 8.1. Target is also Windows 8.1.
The app is caching HTTP GET request. So the second GET request to the same resource returns a cached response. I have tested after disabling the network adapter and I still get a response with the cached results.
I am using jsforce libray to connect to salesforce.com. I know I can add a timestamp on the url but I would like to find fix not a work around.
Any ideas?
[UPDATE]
Issue is not related to jsforce as it works well on Android. The error is specific to Windows 8.1 and cordova.
As suggested in the question, timestamping the url helps: I used:
var url = "https://api.myurl.com/" + param1 + "?" + new Date().getTime()
I wrote a simple library to add caching to REST requests for Cordova: https://github.com/glauber-md/mobile-simple-web-call#using-this-library .
The library will use a local database (sqlite) to fetch server data and cache it locally where applicable (e.g. HTTP GET requests with cache-related headers).
Once it receives a 304 Response, it will use the cached data.
To send a GET request, you'd use:
wscall.get(
'http://myserver.org/users/1234',
// (Optional) query strings
null,
function(responseData) {
// Do something when the response is successful
},
function(error) {
// Do something when an error happens
}
);
Then the data would come from remote server or local cache depending of the HTTP server response.
Maybe it will help you.

Symfony2, jQuery Ajax request, web debug toolbar, 500 Internal Server Error

I am developing an application with Symfony2 platform that, at one moment, makes a simple AJAX request on document ready.
jQuery.ajax({
url: 'test.php',
type: 'POST',
data: {
'test': 'test'
},
success: function( response ){
jQuery( 'div#container' ).html( response );
}
});
The problem is that on app_dev.php, where the debug toolbar is loaded, an 500 error is throwed.
More precisely, the AJAX response from the 'test.php' file is received and loaded in the div container, but then, when it tries to load the toolbar, I receive an alert message:
"An error occured while loading the web debug toolbar (500: Internal
Server Error). Do you want to open the profiler?"
If I open profiler, I don't see anything wrong.
If I open the xhr request for the toolbar, a FastCGI 500 error is displayed:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP54_via_FastCGI
Error Code 0x000000ff
If I don't try to make the AJAX request, the toolbar is loaded with no problem.
If I make the request by hand (event on a button) after the toolbar is loaded, again, no problem. If I make the request by hand (event on a button) before the toolbar is loaded the error is throwed.
Notes:
This error occur only on the local machine (with ISS 7.5, PHP 5.4.14). On the production server (IIS server 8.0, same and PHP) the AJAX request is made, and the toolbar is loaded with no problems. I have replaced the php.ini on the local machine with the php.ini from the production server - same problem.
Initialy AJAX request was loading the result of a simple bundle controller method, but then I have tried with a simple PHP file 'test.php', same problem.
I have tried with post and get methods to make the request.
Does anyone have any ideea what goes wrong?
This is not a serious problem since I have multiple options the develop this app, but is bugging me, and I already lost a enough time with this.
PS: if it make any difference, on same machine I have developed an application - no framework - that makes, multiple simultaneos ajax requests.
The following will not fix your error, but provides an alternative way to possibly achieve your need. It seems you want to load asynchronously a part of your website, Symfony2 provides a solution for that: ESI render.
The doc is here: http://symfony.com/doc/current/book/templating.html#asynchronous-content-with-hinclude-js
This method will create an ajax call only then your page will be rendered.

Angular JS $http request does not reach the server in ie8

I'm having issues with using $http on ie8. The request does not reach the server, until I hit a refresh. Coming back to the same link still has the same problem until I hit refresh again.
The weird thing is if the web server is on LAN and the request is made to a server in LAN, it works fine. But if the webserver is hosted remotely, it does not work!
Here is the code:
Index.html
{{test}}
Controller
app.controller(
"TestController",
function( $scope, $http) {
var url = '/test/get_data';
$http.get(url).success(function(data) {
$scope.test = data;
});
}
);
I got this error: TypeError: Object doesn't support this property or methodundefined
I prepared a JSFiddle earlier but JSFiddle is broken in ie8 so I don't provide it here.
Unfortunately I don't have a remote server that I can share with you.
Edit
Previously I used an external url which gave me 'Access Denied' error in ie because of Same Origin Policy as mentioned by one answer below. But this was not my original problem. I still have the issue above when request is from the same origin
This is a cross domain request, which is not allowed in ajax because of Same Origin Policy.
There are two solutions for this
1. JSONP: It is a cross browser way to handle cross domain ajax requests using javascript callback mechanism
2. CORS: It is a HTML5 standard, it is implemented by most of the modern browsers except IE
Mongodb lab is not supporting jsonp since it has support for CORS, that is why your request is failing in IE and works in Chrome and other browsers.
As per this post they do not have any plan to support jsonp, so I don't thick there is a way to make this work in IE.
So I found the fix... Hope this helps anyone out there that experience this problem
Angular script needs to be loaded after jQuery. I didn't have this because Yii framework that I use autoloads jQuery and the angular was not included after the jQuery.
All the controller functions need to be at the end of body section (just before the closing )
Updating to angular 1.0.5 seems to fix the problem. The problem occurred in 1.0.4 with all the above tricks. I think is related to fix 791804bd

Resources