Lorsque vous utiliser le cURL votre api vous retourne t-elle toutes les
données dont vous avez besoin ?
si c'est le cas, avez vous pris en compte les cors dans votre API, cela
peut parfois être également une source d'erreur pour ceux qui consomme
l'API.

Vous pouvez installer les cors avec :

pip install django-cors-headers

puis ajout l'application dans votre INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'corsheaders',
    ...)

en suite dans votre middleware :

MIDDLEWARE_CLASSES = [
    ...
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...]
mettre CoreMiddleware le plus haut possible.

En suite ajouter  CORS_ORIGIN_ALLOW_ALL=True (dans votre settings.py)

Puis en fin : ajouter les hotes autoriser:

CORS_ORIGIN_WHITELIST = (
    'hostname.example.com',
    'localhost:8000',
    '127.0.0.1:9000')
NB : préciser les votres.


Et si vous vérifiez tout cela et que le problème ne vient pas de la,
merci de vérifier votre code java(ce service qui consomme votre API)


J'espère que cela va vous aider, Merci !

Le lun. 8 avr. 2019 à 11:23, Minhaj Nadeem <minhaj....@gmail.com> a écrit :

> Hi everyone,
> I am new to Django Rest Framework. I have developed a program using
> pyCharm. A local url that gets list of users. It is working fine on web, I
> tried to execute this API from android App but it return *null *response.
> please tell me how can i have working API on android App. Thank you!
>
> --
> Best Regards,
> *Muhammad Minhaj Nadeem*
> *Software engineer*
> *Cell: +92 334 6241289 *
>
> LinkedIn <http://www.linkedin.com/in/minhaj-nadeem-521a40a0> | Skype
> <https://join.skype.com/invite/ogC5HriiUYZz>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAwTtYi9yKWEGPOqwze6s-dY995PrWPdfVWV4egnc9p4K9vTMw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAwTtYi9yKWEGPOqwze6s-dY995PrWPdfVWV4egnc9p4K9vTMw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO73PDozoQDOA7q2PSPrJ_3R3VGeTwsmnHV_4j5EcPaLPWL1uA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to