IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API, COM et SDKs Delphi Discussion :

URSSAF API DPAE


Sujet :

API, COM et SDKs Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Inscrit en
    Janvier 2014
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Janvier 2014
    Messages : 5
    Par défaut URSSAF API DPAE
    Bonjour,

    je cherche a mettre en place une implémentation de l'API DPAE
    j'arrive a m'authentifier https://mon.urssaf.fr/authentifier_dpae et recevoir un jeton

    quand j'essaie de faire un dépôt comme décrit dans page 5 du document https://www.dpae-edi.urssaf.fr/5492-...ementation.pdf voir ci-dessous
    j'obtient l'erreur 422 : 'Unprocessable Entity'

    merci par avance de votre aide
    POST /deposer-dsn/1.0/ HTTP/1.1
    Host: depot.dpae-edi.urssaf.fr
    Authorization:
    Content-Type: text/plain
    Content-Encoding : gzip
    Content-Length: 4096
    Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
     
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <FR_DUE_Upload xmlns:cct="urn:oasis:names:tc:ubl:corecomponentTypes:1.0:0.70"
    xmlns:rxdt="http://www.repxml.org/DataTypes"
    xmlns:rxorg="http://www.repxml.org/Organization"
    xmlns:rxpadr="http://www.repxml.org/PostalAddress"
    xmlns:rxpers="http://www.repxml.org/Person_Identity"
    xmlns:rxphadr="http://www.repxml.org/PhoneAddress"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
     <FR_DUE_Upload.Test.Indicator>120</FR_DUE_Upload.Test.Indicator>
     <FR_DuesGroup>
     <FR_Employer>
     <FR_EmployerIdentity>
     
    <rxorg:FR_Organization.SIRET.Identifier>99999999999999</rxorg:FR_Organization.SIRE
    T.Identifier>
     
     <rxorg:FR_Organization.APE.Code>8110Z</rxorg:FR_Organization.APE.Code>
     </FR_EmployerIdentity>
     <FR_Employer.URSSAF.Code>257</FR_Employer.URSSAF.Code>
     <FR_EmployerAddress>
     <rxpadr:FR_PostalAddress.StreetDesignation.Text>44 rue DES
    TEST</rxpadr:FR_PostalAddress.StreetDesignation.Text>
     
    <rxpadr:FR_PostalAddress.Town.Text>CAEN</rxpadr:FR_PostalAddress.Town.Text>
     
    <rxpadr:FR_PostalAddress.Postal.Code>14000</rxpadr:FR_PostalAddress.Postal.Code>
     </FR_EmployerAddress>
     <FR_EmployerContact><FR_PhoneNumber>
     
    <rxphadr:FR_PhoneAddress.PhoneNumber.Text>0000000000</rxphadr:FR_PhoneAddress.Phon
    eNumber.Text>
     </FR_PhoneNumber>
     </FR_EmployerContact>
     </FR_Employer>
    <FR_EmployeeGroup>
     <FR_Employee>
     <FR_EmployeeIdentity>
     
    <rxpers:FR_PersonIdentity.Surname.Text>TEST</rxpers:FR_PersonIdentity.Surname.Text
    >
     
    <rxpers:FR_PersonIdentity.ChristianName.Text>Alain</rxpers:FR_PersonIdentity.Chris
    tianName.Text>
     
    <rxpers:FR_PersonIdentity.Sex.Code>1</rxpers:FR_PersonIdentity.Sex.Code>
     <rxpers:FR_NNI>
    <rxpers:FR_NNI.NIR.Identifier>1000000000000</rxpers:FR_NNI.NIR.Identifier>
    <rxpers:FR_NNI.NIRKey.Text>99</rxpers:FR_NNI.NIRKey.Text>
     </rxpers:FR_NNI>
     <rxpers:FR_Birth>
     <rxpers:FR_Birth.Date>1970-01-01</rxpers:FR_Birth.Date>
     <rxpers:FR_Birth.Town.Text>PARIS</rxpers:FR_Birth.Town.Text>
     </rxpers:FR_Birth>
     </FR_EmployeeIdentity>
     <FR_EmployeeComplement>
     
    <FR_EmployeeComplement.Birth_Department.Code>75</FR_EmployeeComplement.Birth_Depar
    tment.Code>
     </FR_EmployeeComplement>
     </FR_Employee>
     <FR_Contract>
     <FR_Contract.StartContract.Date>2015-07-
    17</FR_Contract.StartContract.Date>
     
    <FR_Contract.StartContract.Time>12:30:00</FR_Contract.StartContract.Time>
     <FR_Contract.EndContract.Date>2015-09-
    15</FR_Contract.EndContract.Date>
     <FR_Contract.Nature.Code>CDI</FR_Contract.Nature.Code>
     
    <FR_Contract.HealthService.Text>387</FR_Contract.HealthService.Text>
     </FR_Contract>
     </FR_EmployeeGroup>
     </FR_DuesGroup>
     </FR_DUE_Upload>

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 577
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 577
    Billets dans le blog
    65
    Par défaut
    Bonjour et bienvenue,

    rien qu'en mettant les balise de codes on voit qu'il y a deux choses distinctes, ce qu'il faut mettre dans les propriétés du composant utilisé pour faire le POST
    et le contenu à envoyer (un fichier XML).
    Tout cela me fait penser au RESTDebugger

    j'ai ensuite un doute faut-il le compresser avant comme semble l'indiquer Content-Encoding : gzip ou est-ce que c'est le composant qui le fait ?



    Cela dit je ne suis pas un spécialiste de ce genre de chose

  3. #3
    Membre chevronné Avatar de blonde
    Femme Profil pro
    Développeur Delphi
    Inscrit en
    Septembre 2003
    Messages
    278
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Delphi

    Informations forums :
    Inscription : Septembre 2003
    Messages : 278
    Par défaut
    D'après cette doc : https://developer.mozilla.org/fr/doc...TTP/Status/422

    ton envoi est bien formé, mais c'est le serveur de l'Urssaf qui ne peut gérer ta demande. Je ne suis pas étonnée si tu me dis que tu envoies directement sur un environnement de production et pas un environnement de test.
    Est-ce que tu as la possibilité de discuter avec le service qui s'occupe du SI DPAE à l'Urssaf ? Je pense qu'ils peuvent te mettre un environnement de test à disposition. Voire même quelques scripts de démo.

    Tu as déjà fait des tests avec un autre outil comme le suggère SergioMaster ? RestDebugger ou des addon de navigateur ?

  4. #4
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    sans avoir creusé, le premier truc qui me saute aux yeux c'est Content-Type: text/plain alors que tu envoies du XML...bon la doc semble indiquer que c'est ce qu'il faut mettre, mais ça me surprend.

    pour ce qui est du content-encoding, il est indiqué GZIP alors que le contenu n'est pas compressé !

    le content-length de 4096 correspond-il à quelque chose de réel ? cette valeur en puissance de 2 est surprenante également.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Futur Membre du Club
    Inscrit en
    Janvier 2014
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Janvier 2014
    Messages : 5
    Par défaut
    Merci de votre retour, voici le code qui fonctionne pour l'authentification mais il génère 422 pour le dépôt, au niveau de l’URSSAF je n'ai pas de réponse, il répondent qu'au compte goûte
    le content est compressé et d’après la documentation il faut mettre le Content-Type: text/plain
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    unit Unit2;
     
    interface
     
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls
        , System.Net.HttpClient;
     
    type
      TForm2 = class(TForm)
        Authentification: TButton;
        Envoyer: TButton;
        Memo_Token: TMemo;
        procedure AuthentificationClick(Sender: TObject);
        procedure EnvoyerClick(Sender: TObject);
      private
        F_Token,
          F_Http_Query,
          F_Http_Body,
          F_Content_Type,
          F_Content_Encoding,
          f_motdepasse: String;
        F_Query_Get_Stream: TStringStream;
        F_HttpClient: THttpClient;
        F_HttpResponse: IHttpResponse;
        function Do_Execute_Query_Post: String;
        procedure Prepare_Query_Get_Stream(aParametre: String);
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form2: TForm2;
     
    implementation
     
    uses System.ZLib;
    {$R *.dfm}
     
     
    procedure TForm2.AuthentificationClick(Sender: TObject);
    begin
      f_motdepasse := '6AQ3UKQH';
      F_Http_Query := 'https://mon.urssaf.fr/authentifier_dpae';
     
      F_Content_Type := 'application/xml';
      F_Http_Body := '<identifiants>'
        + '<siret>0000000000</siret>'
        + '<nom>nom</nom>'
        + '<prenom>prenom</prenom>'
        + '<motdepasse>motdepasse</motdepasse>'
        + '<service>25</service>'
        + '</identifiants>';
      Do_Execute_Query_Post;
      F_Token := F_HttpResponse.ContentAsString();
      Memo_Token.Text :=
        'StatusCode=' + inttostr(F_HttpResponse.StatusCode) + #13
        + 'StatusText=' + F_HttpResponse.StatusText + #13
        + 'Content=' + F_HttpResponse.ContentAsString() + #13
    end;
     
    procedure TForm2.Prepare_Query_Get_Stream(aParametre: String);
    var
      s: string;
      function ZCompressString(aText: string): string;
      var
        strInput: TStringStream;
      begin
        F_Query_Get_Stream := TStringStream.Create;
        strInput := TStringStream.Create(aText);
        strInput.Seek(0, TSeekOrigin.soBeginning);
        ZCompressStream(strInput, F_Query_Get_Stream);
      end;
     
    begin
      FreeAndnil(F_Query_Get_Stream);
      F_Query_Get_Stream := nil;
      if aParametre <> '' then
      begin
        if F_Content_Encoding = '' then
        begin
          F_Query_Get_Stream := TStringStream.Create(aParametre, TEncoding.UTF8);
        end
        else
        begin
          ZCompressString(aParametre);
        end;
      end;
    end;
     
    function TForm2.Do_Execute_Query_Post: String;
    var
      F_HttpClient: THttpClient;
    begin
      try
        F_HttpClient := THttpClient.Create;
     
        F_HttpClient.ContentType := F_Content_Type;
        if F_Content_Encoding <> '' then
        begin
          F_HttpClient.AcceptEncoding := F_Content_Encoding;
          F_HttpClient.CustomHeaders['Content-Encoding'] := F_Content_Encoding;
        end;
     
        if F_Token <> '' then
          F_HttpClient.CustomHeaders['Authorization'] := 'DSNLogin jeton=' + F_Token + #13;
     
        Prepare_Query_Get_Stream(F_Http_Body);
     
        F_HttpResponse := F_HttpClient.Post(F_Http_Query, F_Query_Get_Stream);
        result := F_HttpResponse.ContentAsString();
        FreeAndnil(F_Query_Get_Stream);
      finally
        F_HttpClient.DisposeOf;
      end;
     
    end;
     
    procedure TForm2.EnvoyerClick(Sender: TObject);
      function GET_DUE: String;
      begin
       result :=
          ' <?xml version="1.0" encoding="UTF-8"?> '
          + ' <FR_DUE_Upload xmlns:cct="urn:oasis:names:tc:ubl:corecomponentTypes:1.0:0.70" '
          + '                      xmlns:rxdt="http://www.repxml.org/DataTypes" xmlns:rxorg="http://www.repxml.org/Organization" xmlns:rxpadr="http://www.repxml.org/PostalAddress" xmlns:rxpers="http://www.repxml.org/Person_Identity"  '
          + '  xmlns:rxphadr="http://www.repxml.org/PhoneAddress" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> '
          + '    <FR_DUE_Upload.Test.Indicator>120</FR_DUE_Upload.Test.Indicator> '
          + '    <FR_DuesGroup> '
          + '       <FR_Employer> '
          + '          <FR_EmployerIdentity> '
          + '             <rxorg:FR_Organization.SIRET.Identifier>99999999999999</rxorg:FR_Organization.SIRET.Identifier> '
          + '             <rxorg:FR_Organization.APE.Code>8110Z</rxorg:FR_Organization.APE.Code> '
          + '          </FR_EmployerIdentity> '
          + '          <FR_Employer.URSSAF.Code>257</FR_Employer.URSSAF.Code> '
          + '          <FR_EmployerAddress> '
          + '             <rxpadr:FR_PostalAddress.StreetDesignation.Text>44 rue DES TEST</rxpadr:FR_PostalAddress.StreetDesignation.Text> '
          + '             <rxpadr:FR_PostalAddress.Town.Text>CAEN</rxpadr:FR_PostalAddress.Town.Text> '
          + '             <rxpadr:FR_PostalAddress.Postal.Code>14000</rxpadr:FR_PostalAddress.Postal.Code> '
          + '          </FR_EmployerAddress> '
          + '          <FR_EmployerContact> '
          + '             <FR_PhoneNumber> '
          + '                <rxphadr:FR_PhoneAddress.PhoneNumber.Text>0000000000</rxphadr:FR_PhoneAddress.PhoneNumber.Text> '
          + '             </FR_PhoneNumber> '
          + '          </FR_EmployerContact> '
          + '       </FR_Employer> '
          + '       <FR_EmployeeGroup> '
          + '          <FR_Employee> '
          + '             <FR_EmployeeIdentity> '
          + '                <rxpers:FR_PersonIdentity.Surname.Text>TEST</rxpers:FR_PersonIdentity.Surname.Text> '
          + '                <rxpers:FR_PersonIdentity.ChristianName.Text>Alain</rxpers:FR_PersonIdentity.ChristianName.Text> '
          + '                <rxpers:FR_PersonIdentity.Sex.Code>1</rxpers:FR_PersonIdentity.Sex.Code> '
          + '                <rxpers:FR_NNI> '
          + '                   <rxpers:FR_NNI.NIR.Identifier>1000000000000</rxpers:FR_NNI.NIR.Identifier> '
          + '                   <rxpers:FR_NNI.NIRKey.Text>11</rxpers:FR_NNI.NIRKey.Text> '
          + '                </rxpers:FR_NNI> '
          + '                <rxpers:FR_Birth> '
          + '                   <rxpers:FR_Birth.Date>1970-01-01</rxpers:FR_Birth.Date> '
          + '                   <rxpers:FR_Birth.Town.Text>PARIS</rxpers:FR_Birth.Town.Text> '
          + '                </rxpers:FR_Birth> '
          + '             </FR_EmployeeIdentity> '
          + '             <FR_EmployeeComplement> '
          + '                <FR_EmployeeComplement.Birth_Department.Code>75</FR_EmployeeComplement.Birth_Department.Code> '
          + '             </FR_EmployeeComplement> '
          + '          </FR_Employee> '
          + '          <FR_Contract> '
          + '             <FR_Contract.StartContract.Date>2020-08-17</FR_Contract.StartContract.Date> '
          + '             <FR_Contract.StartContract.Time>12:30:00</FR_Contract.StartContract.Time> '
          + '             <FR_Contract.EndContract.Date>2020-09-15</FR_Contract.EndContract.Date> '
          + '             <FR_Contract.Nature.Code>CDI</FR_Contract.Nature.Code> '
          + '             <FR_Contract.HealthService.Text>387</FR_Contract.HealthService.Text> '
          + '          </FR_Contract> '
          + '       </FR_EmployeeGroup> '
          + '    </FR_DuesGroup> '
          + ' </FR_DUE_Upload> ';
      end;
     
    begin
     
      F_Http_Body := GET_DUE;
     
      F_Content_Type := 'text/plain'; // 'application/xml';
      F_Content_Encoding := 'gzip';
      F_Http_Query := 'https://depot.dpae-edi.urssaf.fr/deposer-dsn/1.0';
     
      Do_Execute_Query_Post;
     
      Memo_Token.Text :=
        'StatusCode=' + inttostr(F_HttpResponse.StatusCode) + #13#10
        + 'StatusText=' + F_HttpResponse.StatusText + #13#10
        + 'Content=' + F_HttpResponse.ContentAsString() + #13#10
     
    end;
     
    end.

  6. #6
    Membre chevronné Avatar de blonde
    Femme Profil pro
    Développeur Delphi
    Inscrit en
    Septembre 2003
    Messages
    278
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Delphi

    Informations forums :
    Inscription : Septembre 2003
    Messages : 278
    Par défaut
    J'ai vu ça sur ta doc : Les concentrateurs doivent préciser le port 8443 dans l’url des services de dépôt,
    consultation et téléchargement (pas pour le service d’authentification)


    Est-ce que tu as précisé le port ? Je ne l'ai pas trouvé dans ton code.

    J'ai aussi lu ça :
    L’exemple ne tient pas compte des diverses transformations appliquées au message (gzip, chunk, ssl…).
    Donc l'exemple fourni n'est peut-être pas bon. Tu as essayé sans compression ?

    Je pensais aussi au 's' du https, mais apparemment il n'y a pas d'erreur à ce niveau. Je pense que le serveur t'aurais envoyé balader avec une autre erreur.

  7. #7
    Membre averti
    Homme Profil pro
    Développeur 4D
    Inscrit en
    Novembre 2007
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur 4D

    Informations forums :
    Inscription : Novembre 2007
    Messages : 14
    Par défaut L'authentification
    Citation Envoyé par Dev_detif Voir le message
    f_motdepasse := '6AQ3UKQH';
    F_Http_Query := 'https://mon.urssaf.fr/authentifier_dpae';

    F_Content_Type := 'application/xml';
    F_Http_Body := '<identifiants>'
    + '<siret>0000000000</siret>'
    + '<nom>nom</nom>'
    + '<prenom>prenom</prenom>'
    + '<motdepasse>motdepasse</motdepasse>'
    + '<service>25</service>'
    + '</identifiants>';
    Bonjour,

    Serait il possible d'avoir plus d'info sur l'authentification.

    Dans ton code, tu fournis il y a une variable f_motdepasse : pour quoi, de où sort elle ?

    Pour tester, je n'utilise que mes identifiants perso URSSAF: un siret (qui n'est pas celui de ma société), nom, prénom, mdp (comme pour me connecter au site et payer ma dîme)

    Ma requête retourne sans cesse une erreur 422

    Merci

Discussions similaires

  1. Documentation gratuite sur l'API Windows, COM, DCOM, OLE, etc.
    Par Community Management dans le forum Windows
    Réponses: 1
    Dernier message: 16/11/2006, 15h28
  2. JEG : jAPI : Une API pour C++Builder
    Par JEG dans le forum C++Builder
    Réponses: 4
    Dernier message: 15/11/2003, 13h50
  3. FOnction api specifiant la position de la souris
    Par florent dans le forum C++Builder
    Réponses: 4
    Dernier message: 15/05/2002, 20h07
  4. faire un selection dans une image aves les APIs
    Par merahyazid dans le forum C++Builder
    Réponses: 3
    Dernier message: 30/04/2002, 10h44
  5. Une petite aide pour les API ?
    Par Yop dans le forum Windows
    Réponses: 2
    Dernier message: 04/04/2002, 21h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo