Skip to content

Commit

Permalink
Merge pull request #1173 from AnuGayan/2.x.x
Browse files Browse the repository at this point in the history
Allow exporting APIs with spaces in the name
  • Loading branch information
npamudika authored Jul 29, 2024
2 parents bb357fa + 9386e4c commit 8daec7e
Showing 1 changed file with 6 additions and 7 deletions.
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

0 comments on commit 8daec7e

Please sign in to comment.