Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow exporting APIs with spaces in the name #1173

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions import-export-cli/cmd/exportAPI.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ package cmd

import (
"fmt"
"github.com/wso2/product-apim-tooling/import-export-cli/credentials"
"io/ioutil"
"net/url"
"os"
"strconv"

"github.com/wso2/product-apim-tooling/import-export-cli/credentials"

"github.com/go-resty/resty/v2"
"github.com/spf13/cobra"
"github.com/wso2/product-apim-tooling/import-export-cli/utils"
Expand Down Expand Up @@ -132,20 +132,19 @@ func WriteToZip(exportAPIName, exportAPIVersion, zipLocationPath string, resp *r
// @return response Response in the form of *resty.Response
func getExportApiResponse(name, version, provider, format, apiImportExportEndpoint, b64encodedCredentials string, preserveStatus bool, ignoreSwagger bool) (*resty.Response, error) {
apiImportExportEndpoint = utils.AppendSlashToString(apiImportExportEndpoint)
query := "export-api?name=" + name + "&version=" + version + "&provider=" + provider +
query := "export-api?name=" + url.QueryEscape(name) + "&version=" + version + "&provider=" + provider +
"&preserveStatus=" + strconv.FormatBool(preserveStatus) +
"&ignoreSwagger=" + strconv.FormatBool(ignoreSwagger)
if format != "" {
query += "&format=" + format
}

url := apiImportExportEndpoint + query
utils.Logln(utils.LogPrefixInfo+"ExportAPI: URL:", url)
urlString := apiImportExportEndpoint + query
utils.Logln(utils.LogPrefixInfo+"ExportAPI: URL:", urlString)
headers := make(map[string]string)
headers[utils.HeaderAuthorization] = utils.HeaderValueAuthBasicPrefix + " " + b64encodedCredentials
headers[utils.HeaderAccept] = utils.HeaderValueApplicationZip

resp, err := utils.InvokeGETRequest(url, headers)
resp, err := utils.InvokeGETRequest(urlString, headers)

if err != nil {
return nil, err
Expand Down