Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › httprequest issue

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23718

    Felgo User

    Hi,

    I have a endpoint “https://kitchenno1ct.com/wp-json/insmeal/order_api/updateonneworders“, which I can access directly from web, and curl.

    However, when I am using httprequest, I received 406 error, below is a snippet of my code.

    Please advise on where I made problem?

    Thanks,

     

    Jun

    console.log("online order: " + JSON.stringify(data))
            let url = _storeinfo.web_url + "order_api/updateonneworders";
            console.log("ep: " + url)
            var request = HttpRequest
            .get(url)
            //.set('Content-Type', 'application/json; charset=UTF-8')
            //.set('Accept', '*/*')
            //.send(data)
            .timeout(_http_timeout)
            .then(function(res) {
                console.log("body: " + JSON.stringify(res.body) ) // keep JSON result
                populateModel(res.body, _storeinfo.web_url)
            })
            .catch(function(err) {
                console.log(err.message)
                //console.log(err.response)
                console.log("err: " + JSON.stringify(err))
            });
    #23720

    Alex
    Felgo Team

    Hi,

    the full error returned from the request is:

    Not Acceptable!
    
    An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security

    You either need to update your security rules or probably you can add Accept headers to your request to make it through the server security configuration.

    Best,
    Alex

    #23722

    Felgo User

    Hi Alex,

    thanks for your quick reply.

    I tried accepct application/json or Accept */*. and received same error. please see below snippet.

    Can you please advise?

    For the full error return, how to print that? My err.message return only not acceptable, and err returns only status code.

    Jun

     

    var request = HttpRequest
            .get(url)
            .set('Accept', 'application/json')
            //.set('Content-Type', 'application/json; charset=UTF-8')
            //.set('Accept', '*/*')
    #23723

    Alex
    Felgo Team

    Hi,

    I used the standard XMLHttpRequest to double check, and just printed the full response there:

    var xhr = new XMLHttpRequest
    xhr.onreadystatechange = function() {
      if (xhr.readyState === XMLHttpRequest.DONE) {
        console.debug(xhr.responseText)
      }
    }
    xhr.open("GET", "https://kitchenno1ct.com/wp-json/insmeal/order_api/updateonneworders")
    xhr.send()

    “Accept */*” is already the default value if none is provided afaik, so that might even be the problem why your server denies the request, maybe it expects a less general value?

    Best,
    Alex

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded