Created
July 12, 2019 22:42
-
-
Save gitfvb/3e6d7cfb8df6cce4043dbe5b61f2b156 to your computer and use it in GitHub Desktop.
EpiServer Campaign SOAP calls via PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
https://world.episerver.com/documentation/developer-guides/campaign/SOAP-API/introduction-to-the-soap-api/webservice-overview/ | |
WSDL: https://api.campaign.episerver.net/soap11/RpcSession?wsdl | |
#> | |
#--------------------------- | |
# SETTINGS | |
#--------------------------- | |
$mandant = 12345 | |
$user = "api.xxx" | |
$pass = "password" | |
#--------------------------- | |
# SESSION | |
#--------------------------- | |
$soapEnvelopeXml = "<?xml version=""1.0"" encoding=""utf-8""?> | |
<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | |
<soap:Body> | |
<login> | |
<in0>$( $mandant )</in0> | |
<in1>$( $user )</in1> | |
<in2>$( $pass )</in2> | |
</login> | |
</soap:Body> | |
</soap:Envelope>" | |
$header = @{ | |
"SOAPACTION" = "login" | |
} | |
$contentType = "text/xml;charset=""utf-8""" | |
$response = Invoke-RestMethod -Uri "https://api.campaign.episerver.net/soap11/RpcSession" -ContentType $contentType -Method Post -Verbose -Body $soapEnvelopeXml -Headers $header | |
$sessionId = $response.Envelope.Body.loginResponse.loginReturn.'#text' | |
#--------------------------- | |
# MAILINGs | |
#--------------------------- | |
$soapEnvelopeXml = "<?xml version=""1.0"" encoding=""utf-8""?> | |
<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | |
<soap:Body> | |
<getIdsInStatus> | |
<in0>$( $sessionId )</in0> | |
<in1>campaign</in1> | |
<in2>ACTIVATION_REQUIRED</in2> | |
</getIdsInStatus> | |
</soap:Body> | |
</soap:Envelope>" | |
$header = @{ | |
"SOAPACTION" = "getIdsInStatus" | |
} | |
$contentType = "text/xml;charset=""utf-8""" | |
$response = Invoke-RestMethod -Uri "https://api.campaign.episerver.net/soap11/RpcMailing" -ContentType $contentType -Method Post -Verbose -Body $soapEnvelopeXml -Headers $header | |
$smartCampaigns = $response.Envelope.Body.multiRef.'#text' | |
#--------------------------- | |
# LOGOUT | |
#--------------------------- | |
$soapEnvelopeXml = "<?xml version=""1.0"" encoding=""utf-8""?> | |
<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | |
<soap:Body> | |
<logout> | |
<in0>$( $sessionId )</in0> | |
</logout> | |
</soap:Body> | |
</soap:Envelope>" | |
$header = @{ | |
"SOAPACTION" = "logout" | |
} | |
$contentType = "text/xml;charset=""utf-8""" | |
$response = Invoke-RestMethod -Uri "https://api.campaign.episerver.net/soap11/RpcSession" -ContentType $contentType -Method Post -Verbose -Body $soapEnvelopeXml -Headers $header | |
$response.Envelope.Body.logoutResponse | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
https://world.episerver.com/documentation/developer-guides/campaign/SOAP-API/introduction-to-the-soap-api/webservice-overview/ | |
WSDL: https://api.campaign.episerver.net/soap11/RpcSession?wsdl | |
#> | |
#--------------------------- | |
# SETTINGS | |
#--------------------------- | |
$mandant = 12345 | |
$user = "api.xxx" | |
$pass = "password" | |
#--------------------------- | |
# SESSION | |
#--------------------------- | |
$wsdlSession = "https://api.campaign.episerver.net/soap11/RpcSession?wsdl" | |
$epiSession = New-WebServiceProxy -Uri $wsdlSession #-Namespace WebServiceProxy | |
$sessionId = $epiSession.login($mandant,$user,$pass) | |
$sessionId | |
#--------------------------- | |
# MAILINGs | |
#--------------------------- | |
$wsdlMailings = "http://api.campaign.episerver.net/soap11/RpcMailing?wsdl" | |
$epiMailings = New-WebServiceProxy -Uri $wsdlMailings | |
$campaigns = $epiMailings.getIdsInStatus($sessionId, "campaign", "ACTIVATION_REQUIRED") | |
$campaigns | |
$regular = $epiMailings.getIdsInStatus($sessionId, "regular", "DONE") | |
$regular | |
#--------------------------- | |
# LOGOUT | |
#--------------------------- | |
$epiSession.logout($sessionId) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment