using the REST API

Discussion in 'General' started by pssara, Jan 8, 2021.

  1. pssara

    pssara New Member

    Hi,
    I am trying to use the examples given by Till at https://www.howtoforge.com/community/threads/rest-api-examples.79889/ but i cannot even login to the API to get the session id. I get the response :
    Code:
    {"code":"remote_fault","message":"The login failed. Username or password wrong.","response":false}
    I am just using the ispconfig admin interface login and password, right ? or should I use something else?
    thanks,
    Panagiotis
     
    Last edited: Jan 8, 2021
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No, you have to create a remote user and password. See System > remote users.
     
  3. pssara

    pssara New Member

    great! thanks!
     
  4. pssara

    pssara New Member

    sorry to come back.
    so, what I am trying is to create txt records for letsencrypt as my requirements are specific.
    however, I run into the same problem that the acme.sh developers run into at https://github.com/acmesh-official/acme.sh/issues/2696
    when I call the dns_txt_add API, I get the error:
    Code:
    {u'message': u"Incorrect integer value: '' for column `dbispconfig`.`dns_rr`.`sys_userid` at row 1 INSERT INTO `dns_rr` (`server_id`, `zone`, `name`, `type`, `data`, `ttl`, `active`, `stamp`, `serial`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`) VALUES ('1', 'ZONEID', '_acme-challenge.whateverdomain.', 'txt', 'whatevervalue', '60', 'y', '2021-01-08 17:24:15', '2020122803', '', '', 'riud', 'riud', '')", u'code': u'remote_fault', u'response': False}
    have the parameters of the call changed from what is in the documentation?
    thanks, Panagiotis
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    You are passing an invalid client_id to the api that's why you get that error.
     
  6. pssara

    pssara New Member

    if I am not mistaken the client_id is the sys_userid returned from dns_zone_get ? at least the acme.sh does the same.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    No, the client_id is the client_id from client database table.
     
  8. pssara

    pssara New Member

    thanks. but how should i get it from the API ? I just want to create a txt record for a zone.
     
  9. TonyG

    TonyG Active Member

    See client_get_by_username() and client_get_id(). So your pattern is to login to get a session ID, then use that session ID with the user name to get the client ID, then use the client ID to perform other functions.
     
    Jesse Norell likes this.
  10. pssara

    pssara New Member

    thanks Tony. That works now.
     
  11. PaulDG

    PaulDG New Member

    I have a similar problem, using pfsense and the acme plugin.
    The acme plugin's DNS-ISPConfig script issues a dns_zone_get and sets the client id from the returned "sys_userid":"x" which appears to be incremented by 1.
    The first time it issues a "dns_txt_add" it works but this results in the client id being modified by +1. All following calls to "dns_txt_add" fail becouse "dns_zone_get" now returns an invalid "sys_userid"

    I am using ISPConfig 3.2.2 and pfsense acme plugin version 0.6.9_3
    I will try and change the script to use client_get_id() and see what happens.
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    The id can be a totally different number, so it's not a simple +1 increment. You'll have to use the remote api functions if you have just a sys_userid to get the matching client_id.
     
  13. PaulDG

    PaulDG New Member

    Thanks Till, Yeah thats the thing it CAN be totally different number but depending on your own Client layout it can be the same.
    I think the writers of that script have fallen into this trap, like my previous server there client_id must have matched there sys_userid.

    The strange thing is if you follow the link in post number 4, it links to https://github.com/acmesh-official/acme.sh/issues/2705 where someone reports this problem and posts a fix, the fix is discussed, confirmed to work and then stated it will be included.
    That was in Jan 2020 but it has still not made it to the release.

    I made the suggested changes and it has fixed the problem. The fix issues a "client_get_id"

    Thanks for your good work
    Paul
     

Share This Page