NetTalk Central

Author Topic: New API troubles  (Read 3223 times)

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
New API troubles
« on: February 19, 2024, 06:01:08 PM »
Hello all,

     I'm trying a new API in my app.  I have a Users file, and I want to use an API to see if there is an email address in this file.  I want to do a get, see if the email is in the file and then return three fields. 

     On the Parameters tab, I set the parameter type to table, set the table to Users.tps, choose the unique key on the email field, and then check Allow Read.

     On the Returns tab, I set the three fields in the Users table I want to return.  They are:  Usr:EMail, Usr:Access_List and Usr:AcctStatus

The response I get back is:

{
   "EDC_Users_response" : {
      "Usr:EMail" : "",
      "Usr:Access_List" : "",
      "Usr:AcctStatus" : ""
   }
}

     In the "Try It" section of the API documentation, HTTP GET (JSON Response), I set the Usr:Email field to jking@health.usf.edu and this email record does exist in the Users tps file.  I would expect the get to succeed and return the three fields.  Still, I get empty fields.  I can't seem to find where I'm going wrong.  Any thoughts?

Thanks,

Jeff King

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New API troubles
« Reply #1 on: February 19, 2024, 06:09:33 PM »
>> On the Parameters tab, I set the parameter type to table, set the table to Users.tps, choose the unique key on the email field, and then check Allow Read.

this sounds wrong to me. Sounds like the parameter should just be Loc:EmailAddress.

Then in the routine you can write the code to do a fetch on the table etc, and populate the result fields.

Cheers
Bruce

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: New API troubles
« Reply #2 on: February 19, 2024, 06:13:06 PM »
Bruce,

     Should I put the code in the ServiceMethod embed?

Thanks,

Jeff

jking

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
    • Email
Re: New API troubles
« Reply #3 on: February 19, 2024, 08:43:00 PM »
Hi Bruce,

     I have the following code in the ServiceMethod embed:

 Access:Users.Open()
 Access:Users.UseFile()
 Usr:EMail = Clip(EMail)

 
 If Access:Users.Fetch(Usr:EMail_key) = Level:Benign
    EMail = Clip(Usr:EMail)
    Access_List = Clip(Usr:Access_List)
    AcctStatus = Clip(Usr:AcctStatus)
 ELSE
    p_web.AddServiceError(77, '', '', 'The EMail address was not found in the User File!', 'Check the Portal/LIS user account for the proper email address.')
 END


And I'm attempting to test by passing the following URL:

http://127.0.0.1:88/EDC_API/EDC_Users?EMail=jking@health.usf.edu

I'm still getting nothing returned.

Also, when using a local variable, the documentation does not have any "Try It" sections so I can set the EMail variable and do some testing.  See attached image.  Is this expected with local variables as parameters?

Thanks,

Jeff

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: New API troubles
« Reply #4 on: February 20, 2024, 04:02:26 AM »
Hi jking, some ideas...

The code seams ok.

-Are you logged in? from your image you need basic authentication
-Did you add trace lines to see if Email has value?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: New API troubles
« Reply #5 on: February 20, 2024, 06:38:21 AM »
Jeff,

I would expect your code to work, and for the TryItNow to work.

Post me a small example so I can see what you are seeing.

Cheers
Bruce