I am currently having this issue. When I add a query to the server (e.g. http://127.0.0.1:5000/?property=Ward&propertyValue=Ely%20North%20Ward, where Ward = Ely North Ward), the JSON returns values. However, if I wanted to filter Wards that contain the "&" character (e.g. Ward = Ely & Christchurch Ward), it does not return any values, just { type: "FeatureCollection", features: [ ] }.
What can I do so that the function reads "&" characters, and returns the correct values from what I entered?
Code below:
from flask import Flask, escape, request
import requests
import json
def graphqlwfs(url):
url = "https://osdatahubapi.os.uk/OSFeaturesAPI/wfs/v1?service=wfs&request=GetCapabilities"
queryString = "&typenames=osfeatures:BoundaryLine_PollingDistrict&outputformat=geoJSON"
request_json = request.get_json(silent=True)
request_args = request.args
if request_json and 'property' in request_json:
property = request_json['property']
elif request_args and 'property' in request_args:
property = request_args['property']
else:
property = ""
if request_json and 'propertyValue' in request_json:
propertyValue = request_json['propertyValue']
elif request_args and 'propertyValue' in request_args:
propertyValue = request_args['propertyValue']
else:
propertyValue = ""
filterString = "&filter=<Filter><PropertyIsEqualTo><PropertyName>" + str(property) + "</PropertyName><Literal>" + str(propertyValue) + "</Literal></PropertyIsEqualTo></Filter>"
if property == "":
filterString = ""
if propertyValue == "":
filterString = ""
newUrl = str(url.replace("GetCapabilities", "GetFeature") + queryString + filterString)
response = requests.get(newUrl)
features = response.json()
return features
```