Replies: 1 comment 2 replies
-
You will have to built the logic your self. Some pointers: Get-D365LcsApiToken will get a fresh token object, with some details in the output. Armed with this, you can do some calculation on the output from Get-D365LcsApiConfig, which contains activetokenexpireson - that is a unix epoc, which you can translate into a datetime. Or you could just pull a new token, in a loop - just before you do Get-D365LcsDatabaseOperationStatus (but without the -WaitForCompletion parameter). Get-D365LcsApiConfig | Invoke-D365LcsApiRefreshToken | Set-D365LcsApiConfig (with some more details as parameters) Pseudo code: Get-D365LcsApiToken ... | Set-D365LcsApiConfig ...
$temp = Invoke-D365LcsDatabaseRefresh ...
do {
Start-Sleep -Seconds 60
Get-D365LcsApiConfig | Invoke-D365LcsApiRefreshToken | Set-D365LcsApiConfig
$status = $temp | Get-D365LcsDatabaseOperationStatus
}
while (...) I know you're not the first to hit this issue - so I would encourage to write a blog post and even do a PR with a wiki (md) file, where you show how it should be done 😉 Then people can see how it should be done. More than happy to give some pointers and help make the code more solid if you like. |
Beta Was this translation helpful? Give feedback.
-
Hi
I really enjoy the d365fo.tools Module and I really appreciate all the works that has been done.
Currently I start using the Invoke-D365LcsDatabaseRefresh and the Invoke-D365LcsDatabaseExport.
To wait for the completion of the database operation, I use the Get-D365LcsDatabaseOperationStatus with the parameter $WaitForCompletion before continuing other processes.
My question is about on how do you handle the expiration of the Token... let's say that the operation finally take more than 3600 seconds, what is the duration of the token. In that scenario, I should have a System.Net.WebException with status code 401 returned.
Should I add the $EnableException switch parameter and do a try/catch in my own script ?
Maybe is more a question about PSFramework on how it handles the throw of the exception, but I would like to know if someone already handle this and what you would suggest to handle that scenario...
Thx
Francis
Beta Was this translation helpful? Give feedback.
All reactions