Closed zhinu closed 3 years ago
@CamilleRolland
@zhinu I've pushed some changes to the #feat-333 branch to that effect.
Testable here in the meantime : https://v4-notices.bulles.fr/api/v4
@Goutte I'm having issue posting a notice. I think there might be a problem with contributor:"string" Whatever I try (name, id), it just gives me this 400 error :
{
"@context": "/api/v4/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Invalid IRI \"CaptainFact\".",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/var/www/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
"line": 473,
"args": []
},
{
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "->",
"function": "denormalizeRelation",
"file": "/var/www/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
"line": 748,
"args": [
[
"string",
"contributor"
],
[
"object",
"ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata"
],
[
"string",
"App\\Entity\\Contributor"
],
[
"string",
"CaptainFact"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Contributor"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
],
"api_denormalize": [
"boolean",
true
],
"cache_key": [
"string",
"17fb5cb0f507259b5c0a06d648ba4273"
]
}
]
]
},
{
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "->",
"function": "createAttributeValue",
"file": "/var/www/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
"line": 403,
"args": [
[
"string",
"contributor"
],
[
"string",
"CaptainFact"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
],
"api_denormalize": [
"boolean",
true
],
"cache_key": [
"string",
"17fb5cb0f507259b5c0a06d648ba4273"
]
}
]
]
},
{
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "->",
"function": "setAttributeValue",
"file": "/var/www/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php",
"line": 361,
"args": [
[
"object",
"App\\Entity\\Notice"
],
[
"string",
"contributor"
],
[
"string",
"CaptainFact"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
],
"api_denormalize": [
"boolean",
true
],
"cache_key": [
"string",
"17fb5cb0f507259b5c0a06d648ba4273"
]
}
]
]
},
{
"namespace": "Symfony\\Component\\Serializer\\Normalizer",
"short_class": "AbstractObjectNormalizer",
"class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type": "->",
"function": "denormalize",
"file": "/var/www/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
"line": 250,
"args": [
[
"array",
{
"visibility": [
"string",
"public"
],
"matchingContexts": [
"array",
[
[
"array",
{
"exampleUrl": [
"string",
"https://www.primevideo.com/260-7312105-1574049"
],
"urlRegex": [
"string",
"(amazon\\.fr|www\\.amazon\\.com|www\\.amazon\\.fr)(?=.*apple)(?=.*airpods)(?=.*pro)"
],
"excludeUrlRegex": [
"string",
""
],
"description": [
"string",
"lol"
],
"querySelector": [
"string",
""
],
"xpath": [
"string",
"//h1[normalize-space()='Regardez des films et des séries']"
]
}
]
]
],
"contributor": [
"string",
"CaptainFact"
],
"message": [
"string",
"la vie la vrai auchan"
],
"expires": [
"string",
"2031-11-05T00:00:00+02:00"
]
}
],
[
"string",
"App\\Entity\\Notice"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
],
"api_denormalize": [
"boolean",
true
],
"cache_key": [
"string",
"17fb5cb0f507259b5c0a06d648ba4273"
]
}
]
]
},
{
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "->",
"function": "denormalize",
"file": "/var/www/vendor/api-platform/core/src/JsonLd/Serializer/ItemNormalizer.php",
"line": 120,
"args": [
[
"array",
{
"visibility": [
"string",
"public"
],
"matchingContexts": [
"array",
[
[
"array",
{
"exampleUrl": [
"string",
"https://www.primevideo.com/260-7312105-1574049"
],
"urlRegex": [
"string",
"(amazon\\.fr|www\\.amazon\\.com|www\\.amazon\\.fr)(?=.*apple)(?=.*airpods)(?=.*pro)"
],
"excludeUrlRegex": [
"string",
""
],
"description": [
"string",
"lol"
],
"querySelector": [
"string",
""
],
"xpath": [
"string",
"//h1[normalize-space()='Regardez des films et des séries']"
]
}
]
]
],
"contributor": [
"string",
"CaptainFact"
],
"message": [
"string",
"la vie la vrai auchan"
],
"expires": [
"string",
"2031-11-05T00:00:00+02:00"
]
}
],
[
"string",
"App\\Entity\\Notice"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
],
"api_denormalize": [
"boolean",
true
]
}
]
]
},
{
"namespace": "ApiPlatform\\Core\\JsonLd\\Serializer",
"short_class": "ItemNormalizer",
"class": "ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer",
"type": "->",
"function": "denormalize",
"file": "/var/www/vendor/symfony/serializer/Serializer.php",
"line": 196,
"args": [
[
"array",
{
"visibility": [
"string",
"public"
],
"matchingContexts": [
"array",
[
[
"array",
{
"exampleUrl": [
"string",
"https://www.primevideo.com/260-7312105-1574049"
],
"urlRegex": [
"string",
"(amazon\\.fr|www\\.amazon\\.com|www\\.amazon\\.fr)(?=.*apple)(?=.*airpods)(?=.*pro)"
],
"excludeUrlRegex": [
"string",
""
],
"description": [
"string",
"lol"
],
"querySelector": [
"string",
""
],
"xpath": [
"string",
"//h1[normalize-space()='Regardez des films et des séries']"
]
}
]
]
],
"contributor": [
"string",
"CaptainFact"
],
"message": [
"string",
"la vie la vrai auchan"
],
"expires": [
"string",
"2031-11-05T00:00:00+02:00"
]
}
],
[
"string",
"App\\Entity\\Notice"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
]
}
]
]
},
{
"namespace": "Symfony\\Component\\Serializer",
"short_class": "Serializer",
"class": "Symfony\\Component\\Serializer\\Serializer",
"type": "->",
"function": "denormalize",
"file": "/var/www/vendor/symfony/serializer/Serializer.php",
"line": 143,
"args": [
[
"array",
{
"visibility": [
"string",
"public"
],
"matchingContexts": [
"array",
[
[
"array",
{
"exampleUrl": [
"string",
"https://www.primevideo.com/260-7312105-1574049"
],
"urlRegex": [
"string",
"(amazon\\.fr|www\\.amazon\\.com|www\\.amazon\\.fr)(?=.*apple)(?=.*airpods)(?=.*pro)"
],
"excludeUrlRegex": [
"string",
""
],
"description": [
"string",
"lol"
],
"querySelector": [
"string",
""
],
"xpath": [
"string",
"//h1[normalize-space()='Regardez des films et des séries']"
]
}
]
]
],
"contributor": [
"string",
"CaptainFact"
],
"message": [
"string",
"la vie la vrai auchan"
],
"expires": [
"string",
"2031-11-05T00:00:00+02:00"
]
}
],
[
"string",
"App\\Entity\\Notice"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
]
}
]
]
},
{
"namespace": "Symfony\\Component\\Serializer",
"short_class": "Serializer",
"class": "Symfony\\Component\\Serializer\\Serializer",
"type": "->",
"function": "deserialize",
"file": "/var/www/vendor/api-platform/core/src/EventListener/DeserializeListener.php",
"line": 106,
"args": [
[
"array",
{
"visibility": [
"string",
"public"
],
"matchingContexts": [
"array",
[
[
"array",
{
"exampleUrl": [
"string",
"https://www.primevideo.com/260-7312105-1574049"
],
"urlRegex": [
"string",
"(amazon\\.fr|www\\.amazon\\.com|www\\.amazon\\.fr)(?=.*apple)(?=.*airpods)(?=.*pro)"
],
"excludeUrlRegex": [
"string",
""
],
"description": [
"string",
"lol"
],
"querySelector": [
"string",
""
],
"xpath": [
"string",
"//h1[normalize-space()='Regardez des films et des séries']"
]
}
]
]
],
"contributor": [
"string",
"CaptainFact"
],
"message": [
"string",
"la vie la vrai auchan"
],
"expires": [
"string",
"2031-11-05T00:00:00+02:00"
]
}
],
[
"string",
"App\\Entity\\Notice"
],
[
"string",
"jsonld"
],
[
"array",
{
"groups": [
"array",
[
[
"string",
"create"
]
]
],
"version": [
"integer",
4
],
"operation_type": [
"string",
"collection"
],
"collection_operation_name": [
"string",
"post"
],
"api_allow_update": [
"boolean",
false
],
"resource_class": [
"string",
"App\\Entity\\Notice"
],
"iri_only": [
"boolean",
false
],
"input": [
"null",
null
],
"output": [
"null",
null
],
"request_uri": [
"string",
"/api/v4/notices"
],
"uri": [
"string",
"http://localhost:8088/api/v4/notices"
]
}
]
]
},
{
"namespace": "ApiPlatform\\Core\\EventListener",
"short_class": "DeserializeListener",
"class": "ApiPlatform\\Core\\EventListener\\DeserializeListener",
"type": "->",
"function": "onKernelRequest",
"file": "/var/www/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
"line": 126,
"args": [
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher"
]
]
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "WrappedListener",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener",
"type": "->",
"function": "__invoke",
"file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 264,
"args": [
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher"
]
]
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "doDispatch",
"file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 239,
"args": [
[
"array",
[
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
]
]
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
]
]
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "callListeners",
"file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 73,
"args": [
[
"array",
[
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
],
[
"object",
"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener"
]
]
],
[
"string",
"kernel.request"
],
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
]
]
},
{
"namespace": "Symfony\\Component\\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
"line": 168,
"args": [
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
],
[
"string",
"kernel.request"
]
]
},
{
"namespace": "Symfony\\Component\\EventDispatcher\\Debug",
"short_class": "TraceableEventDispatcher",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
"line": 134,
"args": [
[
"object",
"Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
],
[
"string",
"kernel.request"
]
]
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handleRaw",
"file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
"line": 80,
"args": [
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
],
[
"integer",
1
]
]
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->",
"function": "handle",
"file": "/var/www/vendor/symfony/http-kernel/Kernel.php",
"line": 201,
"args": [
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
],
[
"integer",
1
],
[
"boolean",
true
]
]
},
{
"namespace": "Symfony\\Component\\HttpKernel",
"short_class": "Kernel",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "->",
"function": "handle",
"file": "/var/www/public/index.php",
"line": 28,
"args": [
[
"object",
"Symfony\\Component\\HttpFoundation\\Request"
]
]
}
]
}
The important bit is this :
"hydra:description": "Invalid IRI \"CaptainFact\"."
An IRI in our API is like an ID, but fully qualified, like so:
/api/v4/contributors/{id}
You have to know the contributor ID in advance, and there is an endpoint to create a contributor as well.
Matching context was added
Currently, when posting notices using api v4, the only available parameters understood in the body of the post request are :
In order to achieve a full working proof of concept of posting notices via api, we would need to add something similar to that :