Repository: ctreminiom/go-atlassian
Pull request #103 (2022-01-31 05:02:15)

:bug: Fixed the Confluence Content Search endpoint


Patch:
diff --git a/confluence/content.go b/confluence/content.go
index 706ac47..763740e 100644
--- a/confluence/content.go
+++ b/confluence/content.go
@@ -139,7 +139,7 @@ func (c *ContentService) Search(ctx context.Context, cql, cqlContext string, exp
 		query.Add("expand", strings.Join(expand, ","))
 	}
 
-	var endpoint = fmt.Sprintf("/wiki/rest/api/search?%v", query.Encode())
+	var endpoint = fmt.Sprintf("/wiki/rest/api/content/search?%v", query.Encode())
 
 	request, err := c.client.newRequest(ctx, http.MethodGet, endpoint, nil)
 	if err != nil {


Test patch:
diff --git a/confluence/content_test.go b/confluence/content_test.go
index f020b58..4b227f2 100644
--- a/confluence/content_test.go
+++ b/confluence/content_test.go
@@ -406,7 +406,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-contents.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            false,
@@ -421,7 +421,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-contents.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
@@ -436,7 +436,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-contents.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            nil,
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
@@ -451,7 +451,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-contents.json",
 			wantHTTPMethod:     http.MethodPost,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,
@@ -466,7 +466,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/get-contents.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusBadRequest,
 			wantErr:            true,
@@ -481,7 +481,7 @@ func TestContentService_Search(t *testing.T) {
 			maxResults:         50,
 			mockFile:           "./mocks/empty-json.json",
 			wantHTTPMethod:     http.MethodGet,
-			endpoint:           "/wiki/rest/api/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
+			endpoint:           "/wiki/rest/api/content/search?cql=type%3Dpage&cqlcontext=DUMMY&cursor=ca470fa51eb0&expand=space%2Cmetadata.labels&limit=50",
 			context:            context.Background(),
 			wantHTTPCodeReturn: http.StatusOK,
 			wantErr:            true,