NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: jking 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
-
>> 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
-
Bruce,
Should I put the code in the ServiceMethod embed?
Thanks,
Jeff
-
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
-
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?
-
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