08-15-2022 07:41 PM
It shows like below:
Solved! Go to Solution.
08-16-2022 08:56 AM
Hello @is_trouser,
Follow the steps mentioned below in the screen shot, this is an example of uploading CSV using POSTMAN:
Use the following URL to POST: https://<vSZ_IP>:8443/wsg/api/public/v11_0/rkszones/<Zone_ID>/wlans/<WLAN_ID>/dpsk/upload
1. Navigate and click on BODY tab.
2. Choose option "form-data".
3. Under Key Column, click on file drop down menu.
4. Choose option "file" from drop down menu.
5. Under Value column, click on "select-files" and choose the CSV file.
6. Under Key Column, type in "file" as a Key Value.
7. Hit send, if all the CSV data are valid, vSZ should accept the file and create DPSKs.
Regards,
Parik
08-16-2022 08:56 AM
Hello @is_trouser,
Follow the steps mentioned below in the screen shot, this is an example of uploading CSV using POSTMAN:
Use the following URL to POST: https://<vSZ_IP>:8443/wsg/api/public/v11_0/rkszones/<Zone_ID>/wlans/<WLAN_ID>/dpsk/upload
1. Navigate and click on BODY tab.
2. Choose option "form-data".
3. Under Key Column, click on file drop down menu.
4. Choose option "file" from drop down menu.
5. Under Value column, click on "select-files" and choose the CSV file.
6. Under Key Column, type in "file" as a Key Value.
7. Hit send, if all the CSV data are valid, vSZ should accept the file and create DPSKs.
Regards,
Parik
08-17-2022 01:25 AM
Hi @Parik_MN
You are right, I missed the 6th step before. Now it works well in Postman.
But actually I want to run it in PowerShell. I have no idea about it. I have never uploaded file via PowerShell. Could you provide a script sample to me? Thanks a lot!
08-17-2022 01:45 AM
Hello @is_trouser,
Sorry to say this, we are not PowerShell experts. From API logic perspective, I would suggest to use content-type as mentioned below in PowerShell and the DPSK CSV file URL should be used to upload the file.
Any assistance from Ruckus end? Please feel free to chime in.
Content-Type: multipart/form-data
Regards,
Parik
08-17-2022 08:24 PM - edited 08-18-2022 01:14 AM
Hi @Parik_MN I found the solution and test it successfully. Hopefully, it can help other people who has the same issue.
################# Base Info #################
$UrlBase = "https://ac.contoso.com:8443/wsg/api/public";
$apiVer = "v9_1"
$Zone_Id_1 = "69e07745-bac7-4e24-9500-3902960e9700"
$Wlan_Id_1_Office = "45"
################# Create Login Session #################
#Login and transfer Cookie
$Body = [pscustomobject]@{
username = "DPSK_Mgmt"
password = "XXXXXXXXX"
timeZoneUtcOffset = "+08:00"
}
$json = $Body | ConvertTo-Json
$session = Invoke-WebRequest -Uri $UrlBase/$apiVer/session -Method Post -Body $json -ContentType 'application/json' -SessionVariable websession
$stringCookie = [string]$session.Headers["Set-Cookie"]
$cookie = $stringCookie.substring(0,($stringCookie.length - 21))
$headers = @{}
$headers.Add("Cookie",$cookie)
################# Upload DPSK File #################
$FilePath = 'C:/Users/is_trouser/Downloads/batch_dpsk_sample.csv'
$FileName = Split-Path $FilePath -leaf -resolve
$FileBytes = [System.IO.File]::ReadAllBytes($FilePath)
$FileEnc = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($FileBytes)
$boundary = [System.Guid]::NewGuid().ToString()
$LF = "`r`n"
$bodyLines = (
"--$boundary",
"Content-Disposition: form-data; name=`"file`"; filename=`"$FileName`"",
"Content-Type: application/octet-stream$LF",
$FileEnc,
"--$boundary--$LF"
) -join $LF
Invoke-RestMethod -Uri $UrlBase/$apiVer/rkszones/$Zone_Id_1/wlans/$Wlan_Id_1_Office/dpsk/upload -Method POST -Headers $headers -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines -WebSession $websession
################# Remove Login Session #################
Invoke-WebRequest -Uri $UrlBase/$apiVer/session -Method DELETE -ContentType 'application/json'
Notice: CSV file can NOT include any other attributes which is more than sample file and attribute value can NOT be enclosed in quotation marks, otherwise the import will fail with status code 422