Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-19-2020 12:44 PM
hello
I tried to send query cypher to the neo4j database using PHP and I could not do it. what am I doing wrong? Here the error:
Fatal error : Uncaught GuzzleHttp\Exception\ClientException: Client error: POST http://neo4j:***@localhost:7474/db/data/transaction/commit
resulted in a 415 Unsupported Media Type
response in C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{clo in C:\Users\Ali\Desktop\Xamp\htdocs\Projet_Neo4j\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113
06-19-2020 02:02 PM
Hello @abahhar70,
could you post the query and the headers of the HTTP POST, please?
06-19-2020 02:26 PM
06-20-2020 02:21 AM
Thank you @abahhar70
I think that I've found the solution:
415 Unsupported Media Type error occurs when the origin server refuses a particular request since the resource is in a format that is not supported by the server for the HTTP method used. This unsupported format type issue can be caused by what is defined in the resource's Content - Type or Content -Encoding headers.
I think that you're sending an application/json content
with Accept: text/html, application/xhtml+xml, application/xml header.
This is a really good reason to receive a 415 HTTP Error.
Could you try to change it in your request?
06-20-2020 08:38 AM
Hello @abahhar70,
I'm a C++/C# specialist and I didn't know well PHP and GraphAware.
My deduction based on the HTTP error, that seems to give an important info.
I think that u should be able to insert something similar at this php code
.request(MediaType.APPLICATION_JSON)
.header("Content-type", "application/json")
and I've found this topic that maybe should help you more.
This quote is the important part of it:
Your problem is that you don't send Content-Type:application/json , that seems to only be set using function prepareRequest in GraphAware\Neo4j\Client\HttpDriver\Session
06-30-2020 08:36 AM
There are some issues with the headers in the php-client. You must always define content type.
See https://github.com/graphaware/neo4j-php-client/compare/master...Nyholm:headers-fix?expand=1
All the sessions of the conference are now available online