Sending PUT methods through F7

I’ve searching a lot about how to solve this, but I think a little -if not a lot- of help.

So, I’ve made an API in codeigniter restserver (PHP) and it works great in restlet client -for testing purposes, I did some GET and POST methods, they worked fine in my app from Framework7, but I dont’ know how to use method PUT, I will be adding some pictures:
1.- This is app sending data
2.- This is my code
3.- Debugging session
4.- Server working data through restlet client

Anyway, according to the docs in: https://framework7.io/docs/request.html
“For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server”… and I can’t set “application/json” to contentType, because it will send an OPTIONS headers.

What am I missing? Could anyone lend me a hand? Thanks!

Hi @JuanR,

Following is the standard way of putting a XHR request using PUT method.

app.request({
    headers: { /* header object if required */}, (<--- Optional Value)
    url: /* request URL */,
    dataType: 'json',
    contentType: "application/json",
    method: 'PUT',
    data: { /* Additional parameters if you want to send */}, (<--- Optional Value)
    statusCode: {
        404: function (xhr) {
            console.log("URL not found");
        },
        400: function (xhr) {
            console.log("Bad request. Some of the inputs provided to the request aren't valid.");
        },
        401: function (xhr) {
            console.log("Not authenticated. The user session isn't valid.");
        },
        403: function (xhr) {
            console.log("The user isn't authorized to perform the specified request.");
        },
        500: function (xhr) {
            console.log("Internal server error. Additional details will be contained on the server logs.");
        },
        201: function (xhr) {
            console.log("The requested resource has been created.");
        }
    },
    success: function (data, status, xhr) {
        console.log(data);
    },
    error: function (xhr, status) {
        console.log(xhr);
        console.log(JSON.stringify(xhr));
        console.log(status);
    }
}) 

Hope this helps. :slight_smile: