||
Skip to end of metadata
Go to start of metadata

You can enable Git repository notifications via the REST API as shown below:

Overview
DescriptionEnable notifications to be received from the Git repository.
Resource Path

/repo/notify 

HTTP MethodPOST
Request/Response Formatapplication/JSON
Command format
curl -X POST -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/repo/notify
  • The path to the JSON file that defines the GIT repository details needs to be defined as the <JSON_PAYLOAD> value.
  • By default, <USERNAME>:<PASSWORD> is  admin:admin.
  • By default, <PRIVATE_PAAS_HOST> is localhost. However, if you are using a public IP, the respective IP address or domain needs to be specified.
  • By default, <PRIVATE_PAAS_HTTPS_PORT> has been set to 9443. However, if the port offset has been incremented by n, the default port value needs to be incremented by n
Example

Add the Git repository details defined in the  <PRIVATE_PAAS_CARTRIDGES>/git_notifications.json  file.

cd <PRIVATE_PAAS_CARTRIDGES>/
curl -X POST -H "Content-Type: application/json" -d @'git_notifications.json' -k -v -u admin:admin https://localhost:9443/api/repo/notify
Sample output
> POST /api/repo/notify HTTP/1.1
> Host: localhost:9443
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 92
> 
< HTTP/1.1 200 OK
< Date: Mon, 19 Oct 2015 06:48:12 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Server: WSO2 Carbon Server
< 
{"status":"success","message":"Repository notification sent successfully"}

You will come across the following HTTP status codes while enabling the Git repository notifications:

HTTP status code

200, 500

See the descriptions of the HTTP status codes here.

 


 

Sample request
{ 
   "repository":{ 
      "url":"https://github.com/imesh/stratos-php-applications.git"
   }
}

This REST API will be used when setting a WebHook. For more information, see Setting a WebHook at GitHub.

  • No labels