Resolve "Webhooks backend and web-frontend"
Merge Request Checklist
-
changelog.md has been updated if required -
Documentation has been updated -
Quality Standards are met -
The UI/UX has been updated following UI Style Guide -
The redoc API pages have been updated for any REST API changes -
The per database user API docs page has been updated for any REST API changes made to endpoints which can be accessed via a user created token -
Has performance been considered and tested when appropriate? Ideally Baserow should be performant when working with hundreds of thousands of rows -
New/Changed Premium features are separated correctly in the premium folder -
There are tests for and it has been checked that any changed/new django ORM code is sensible, doesn't perform N queries and that table models are not generated needlessly or generated with all columns when only a few are needed.
Closes #257 (closed)
Tips for testing
To test everything I temporarily added the following test code to api/urls.py
:
import json
from django.urls import re_path
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
class Tmp(APIView):
permission_classes = (AllowAny,)
def get(self, request):
print(request.headers)
parsed = json.loads(request.body)
print(json.dumps(parsed, indent=4))
return Response({}, status=200)
...
urlpatterns = (
[
re_path("tmp", Tmp.as_view(), name="tmp"),
...
]
)
What you want to do it start a second Django development server by doing:
docker exec -it baserow_backend_1 bash
python src/baserow/manage.py runserver 0.0.0.0:8001
Because the Django development server only has one worker, this will make sure that when doing a test call the development server is not waiting on itself.
Not you can create a webhook with the following url: http://localhost:8001/api/tmp
and use the test button to make a test call. When actually using the webhook, you need manually change the URL in the database to http://backend:8001/api/tmp
. By changing the response in the Tmp
view, you can test all kinds of scenario's.
- Test a not OK response code.
- Test an endpoint that can't be reached.
- Test a URL that can't be revolved.
- Test an OK endpoint.
Edited by Bram Wiepjes