Nativescript Angular CALDAV Request REPORT?

Viewed 85

Problem:

I would like to send an HTTP Request with the method REPORT (see RFC 4791 ). It should run for android and ios. Therefore I selected Nativescript (Angular) for development.

Development versions:

 tns  --version 7.0.11
 node --version v15.1.0
 npm  --version 7.0.8

I tried 2 approaches:

1. Using Nativescript wrapper of Angular http module.

I've got

JS: "error": {
JS: "originalStack": "Error: java.net.ProtocolException: Expected one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH] 
but was REPORT\n at new ZoneAwareError (file:///data/data/org.nativescript.Ya2Do/files/app/vendor.js:141841:33)\n at onRequestComplete 
(file:///data/data/org.nativescript.Ya2Do/files/app/vendor.js:103522:34)\n at Object.onComplete
(file: node_modules/@nativescript/core/http/http-request/index.android.js:38:0)"
    JS: }`

So it seems REPORT method is not supported in http calls for this approach.

2. Using axios :

Example

const axios = require('axios');

   const options = {
     'headers': {
       'Content-Type': 'text/xml',
       'Authorization': 'Basic xxxxxxxxxxxxxxxxxx=='
     },
     'method': 'REPORT',
     'url': 'http://192.168.0.xxx:5232/xxxxxx/5673B18A-0B74-4725-9BE5-95F0A35E9244',
     timeout: 6000,
     'data': '<?xml version="1.0" encoding="utf-8" ?> \
  <C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav"> \
    <D:prop xmlns:D="DAV:"> \
      <D:getetag/> \
      <C:calendar-data/> \
    </D:prop> \
    <C:filter> \
      <C:comp-filter name="VCALENDAR"> \
        <C:comp-filter name="VTODO"> \
          <C:prop-filter name="RELATED"> \
      <C:is-not-defined/> \
          </C:prop-filter> \
        </C:comp-filter> \
      </C:comp-filter> \
    </C:filter> \
  </C:calendar-query> '
   };

   // Make a request
   axios(options)
     .then((response) => {
       // handle success
       console.log("success");
       console.log("status");
       console.log(response.status);
       console.log("data");
       console.log(response.data);
     })
     .catch(function (error) {
       // handle error
       console.log("error")
       console.log(error);
     })
     .then(function () {
       // always executed
       console.log("finished?")
     }); 

Result:

JS: Angular is running in development mode. Call enableProdMode() to enable production mode.
JS: success
JS: status
JS: null
JS: data
JS:
JS: finished?

Do you have any hint which way to go, to get the required http request working?

Remark 1: GET request is working also with axios and the REPORT request above is working from command line with curl or HTTPie.

Remark 2: The HTTP REPORT request above is running on Windows with node and axios.

Remark 3: The HTTP REPORT request is running with Angular and the provided http module as web application.

0 Answers
Related