Sample PHP code for retrieving asset via API?
Can someone share some complete example PHP code that we could re-use to:
- Authenticate to the API
- Get an Asset
- Edit the retrieved asset Asset
- Update the retrieved Asset
Thanks
Peter
Answers (5)
I don't know PHP either, but perhaps this older thread could help.
https://solutions.teamdynamix.com/TDClient/Forums/Questions/Details?ID=103572
Here is some Python code using this github example library: https://github.com/borwick/tdapi.
#!python
import tdapi
from tdapi.asset import TDAssettd_conn = tdapi.TDConnection(
BEID='REDACTED',
WebServicesKey='REDACTED',
sandbox=False
)tdapi.set_connection(td_conn)
for asset in TDAsset.objects.search({'SerialLike': '123'}):
asset.update({'Tag': 'TAGNUMBER'})
Thanks, Sergio posted an example that got me going so far. I'll share my work back once it's working.
Thanks Mark. Instead of writing it myself I thought I'd reach out to see if someone already had some good prototype code instead of reinventing the wheel. I'm more familiar with PHP than with Python.
Hello Peter,
Unfortunately we do not have the expertise in PHP to provide that for you. I can leave this question open/unanswered so other clients may chime in if they have suggestions for you though.
Out of curiosity, is there a reason that you need specifically PHP code for the API call? Are you only doing scripting with it or are you doing other things as well?
Sincerely,
Mark Sayers
TD Support