Coder Social home page Coder Social logo

How to use? about qtrest HOT 6 CLOSED

qtrest avatar qtrest commented on June 23, 2024
How to use?

from qtrest.

Comments (6)

kafeg avatar kafeg commented on June 23, 2024 1

Hi! Yes, you may to implement some API-classes and use them from different models or by direct.

Did you see example application code? Link: https://github.com/kafeg/qtrest-example

from qtrest.

kafeg avatar kafeg commented on June 23, 2024 1

Hi! Library not supported user/pass authorization by authTokenHeader/authToken
If you send username|password via headers, you must to override method
virtual QNetworkRequest createRequest(const QUrl &url) const;

If you send username/password in request body, you must set them in each request in your API class.

from qtrest.

SafaAlfulaij avatar SafaAlfulaij commented on June 23, 2024

I think I missed that example 😔
Thanks a lot! 👌

from qtrest.

SafaAlfulaij avatar SafaAlfulaij commented on June 23, 2024

I started hacking today and it's going nice :)

One problem is that I'm unable to use the basic HTTP auth method, which uses username and password.
I tried thses, but none of them worked for me:

authTokenHeader: "Authorization"
authToken: "username password"
-----
authTokenHeader: "Basic"
authToken: "password"
-----
authTokenHeader: "username"
authToken: "password"

Maybe something is wrong with the website, but I want to be sure what is the right way to use it!

Thanks a lot! Really nice library. 👏

from qtrest.

SafaAlfulaij avatar SafaAlfulaij commented on June 23, 2024

Yes! Thanks that worked! :)
Now a question, if I have a request that gets an object instead of a list, it it possible to parse it with any method right now? All what I found are lists :)
I found the implementation of getCouponDetail, but it seems it's not used.

An example of returned JSON:

{
    "YML_KEY": {
        "mimetype": "text/plain",
        "file-extensions": ".yml, .yaml",
        "description": "YAML Files based on the content"
    },
    "PHP_INI_KEY": {
        "mimetype": "text/plain",
        "file-extensions": ".ini",
        "description": "PHP INI Files based on content"
    },
    "XLIFF": {
        "mimetype": "text/xml",
        "file-extensions": ".xlf, .xliff, .xml",
        "description": "XLIFF file"
    },
    ...
}

UPDATE

I think I'll inspire from the library as there are several special hacks that I need to to! Thanks anyway! 👍

from qtrest.

kafeg avatar kafeg commented on June 23, 2024

Hi! Please see to function QVariantList AbstractJsonRestListModel::getVariantList(QByteArray bytes) in file src/models/abstractjsonrestlistmodel.cpp

You may use QVariantList and QVariant for get subarray data by QVariant::toJsonArray() / toJsonDocument() / toJsonObject() / toJsonValue().

In QML it's doing automatically, as i test it a year ago)

from qtrest.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.