Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

api-platform mongodb baglanma sorunu


yloibx

Öne çıkan mesajlar

symfony ile api platformda dokumantasyonunda anlattigi gibi basit bir crud operations yapmak istiyorum. ORM ile bunu yaptim. ODM ile yapmak istedigimde execute ettigim an internal 400 hatasi no route found hatasi aliyorum. internette mongodb hakkinda fazla kaynak bulamadim. ben default item operations ile yapmak istiyorum custom controller kullanmadan orm ile oluyordu. odm ile ne farkli oldu anlamadim. 

 

github

https://bit.ly/387uKqL

Link to comment
Sosyal ağlarda paylaş

mongodb'yi de bagladim tutorialda anlatildigi gibi yaptim herseyi ancak herhangi bir operation execute ettigimde invalid iri ve hydra error  hatalarini aliyorum. 

 

swagger ui ile document'te olusturdugum class'lar gozukuyor. post, put, delete islemlerini execute ettigim zaman bu hata ile karsilasiyorum. 

 

{
  "@context": "/api/contexts/Error",
  "@type": "hydra:Error",
  "hydra:title": "An error occurred",
  "hydra:description": "Invalid IRI \"product1\".",
  "trace": [
    {
      "namespace": "",
      "short_class": "",
      "class": "",
      "type": "",
      "function": "",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
      "line": 417,
      "args": []
    },
    {
      "namespace": "ApiPlatform\\Core\\Serializer",
      "short_class": "AbstractItemNormalizer",
      "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      "type": "->",
      "function": "denormalizeRelation",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
      "line": 684,
      "args": [
        [
          "string",
          "product"
        ],
        [
          "object",
          "ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata"
        ],
        [
          "string",
          "App\\Document\\Product"
        ],
        [
          "string",
          "product1"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Product"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ],
            "api_denormalize": [
              "boolean",
              true
            ],
            "cache_key": [
              "string",
              "11906de107f2fd977c81c32553e19974"
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\Serializer",
      "short_class": "AbstractItemNormalizer",
      "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      "type": "->",
      "function": "createAttributeValue",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
      "line": 347,
      "args": [
        [
          "string",
          "product"
        ],
        [
          "string",
          "product1"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ],
            "api_denormalize": [
              "boolean",
              true
            ],
            "cache_key": [
              "string",
              "11906de107f2fd977c81c32553e19974"
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\Serializer",
      "short_class": "AbstractItemNormalizer",
      "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      "type": "->",
      "function": "setAttributeValue",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php",
      "line": 333,
      "args": [
        [
          "object",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "product"
        ],
        [
          "string",
          "product1"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ],
            "api_denormalize": [
              "boolean",
              true
            ],
            "cache_key": [
              "string",
              "11906de107f2fd977c81c32553e19974"
            ]
          }
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\Serializer\\Normalizer",
      "short_class": "AbstractObjectNormalizer",
      "class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
      "type": "->",
      "function": "denormalize",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/Serializer/AbstractItemNormalizer.php",
      "line": 222,
      "args": [
        [
          "array",
          {
            "description": [
              "string",
              "description of first offer"
            ],
            "price": [
              "integer",
              1500
            ],
            "product": [
              "string",
              "product1"
            ]
          }
        ],
        [
          "string",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ],
            "api_denormalize": [
              "boolean",
              true
            ],
            "cache_key": [
              "string",
              "11906de107f2fd977c81c32553e19974"
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\Serializer",
      "short_class": "AbstractItemNormalizer",
      "class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
      "type": "->",
      "function": "denormalize",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/JsonLd/Serializer/ItemNormalizer.php",
      "line": 117,
      "args": [
        [
          "array",
          {
            "description": [
              "string",
              "description of first offer"
            ],
            "price": [
              "integer",
              1500
            ],
            "product": [
              "string",
              "product1"
            ]
          }
        ],
        [
          "string",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ],
            "api_denormalize": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\JsonLd\\Serializer",
      "short_class": "ItemNormalizer",
      "class": "ApiPlatform\\Core\\JsonLd\\Serializer\\ItemNormalizer",
      "type": "->",
      "function": "denormalize",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/serializer/Serializer.php",
      "line": 185,
      "args": [
        [
          "array",
          {
            "description": [
              "string",
              "description of first offer"
            ],
            "price": [
              "integer",
              1500
            ],
            "product": [
              "string",
              "product1"
            ]
          }
        ],
        [
          "string",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\Serializer",
      "short_class": "Serializer",
      "class": "Symfony\\Component\\Serializer\\Serializer",
      "type": "->",
      "function": "denormalize",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/serializer/Serializer.php",
      "line": 136,
      "args": [
        [
          "array",
          {
            "description": [
              "string",
              "description of first offer"
            ],
            "price": [
              "integer",
              1500
            ],
            "product": [
              "string",
              "product1"
            ]
          }
        ],
        [
          "string",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\Serializer",
      "short_class": "Serializer",
      "class": "Symfony\\Component\\Serializer\\Serializer",
      "type": "->",
      "function": "deserialize",
      "file": "/Users/goksel/bookshop-api/vendor/api-platform/core/src/EventListener/DeserializeListener.php",
      "line": 106,
      "args": [
        [
          "array",
          {
            "description": [
              "string",
              "description of first offer"
            ],
            "price": [
              "integer",
              1500
            ],
            "product": [
              "string",
              "product1"
            ]
          }
        ],
        [
          "string",
          "App\\Document\\Offer"
        ],
        [
          "string",
          "jsonld"
        ],
        [
          "array",
          {
            "operation_type": [
              "string",
              "collection"
            ],
            "collection_operation_name": [
              "string",
              "post"
            ],
            "api_allow_update": [
              "boolean",
              false
            ],
            "resource_class": [
              "string",
              "App\\Document\\Offer"
            ],
            "input": [
              "null",
              null
            ],
            "output": [
              "null",
              null
            ],
            "request_uri": [
              "string",
              "/api/offers"
            ],
            "uri": [
              "string",
              "http://127.0.0.1:8000/api/offers"
            ],
            "skip_null_values": [
              "boolean",
              true
            ]
          }
        ]
      ]
    },
    {
      "namespace": "ApiPlatform\\Core\\EventListener",
      "short_class": "DeserializeListener",
      "class": "ApiPlatform\\Core\\EventListener\\DeserializeListener",
      "type": "->",
      "function": "onKernelRequest",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/event-dispatcher/EventDispatcher.php",
      "line": 270,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
        ],
        [
          "string",
          "kernel.request"
        ],
        [
          "object",
          "Symfony\\Component\\EventDispatcher\\EventDispatcher"
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\EventDispatcher",
      "short_class": "EventDispatcher",
      "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
      "type": "::",
      "function": "Symfony\\Component\\EventDispatcher\\{closure}",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/event-dispatcher/EventDispatcher.php",
      "line": 230,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpKernel\\Event\\RequestEvent"
        ],
        [
          "string",
          "kernel.request"
        ],
        [
          "object",
          "Symfony\\Component\\EventDispatcher\\EventDispatcher"
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\EventDispatcher",
      "short_class": "EventDispatcher",
      "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
      "type": "->",
      "function": "callListeners",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/event-dispatcher/EventDispatcher.php",
      "line": 59,
      "args": [
        [
          "array",
          [
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ],
            [
              "object",
              "Closure"
            ]
          ]
        ],
        [
          "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": "/Users/goksel/bookshop-api/vendor/symfony/http-kernel/HttpKernel.php",
      "line": 121,
      "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": "/Users/goksel/bookshop-api/vendor/symfony/http-kernel/HttpKernel.php",
      "line": 67,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpFoundation\\Request"
        ],
        [
          "integer",
          1
        ]
      ]
    },
    {
      "namespace": "Symfony\\Component\\HttpKernel",
      "short_class": "HttpKernel",
      "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
      "type": "->",
      "function": "handle",
      "file": "/Users/goksel/bookshop-api/vendor/symfony/http-kernel/Kernel.php",
      "line": 191,
      "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": "/Users/goksel/bookshop-api/public/index.php",
      "line": 25,
      "args": [
        [
          "object",
          "Symfony\\Component\\HttpFoundation\\Request"
        ]
      ]
    }
  ]
}

 

yloibx tarafından düzenlendi
Link to comment
Sosyal ağlarda paylaş

bu frameworkle ilgili bilgim olmadigindan cevap veremiyorum ? eminim basit biseydir.

mongodb kullanma? binlerce write per sec olmadigi surece relational database her seyi halledebilir, maksat ilerleyip ogrenmek

 

biraz baktim ama

 

/**

* @ODM\Id(strategy="INCREMENT", type="integer")

*/

private $id;

 

sanki id'yi "product1" diye sorguluyorsun bu da integer degil. bi temizleyip bastan dene idyi string yap istersen vs.

Link to comment
Sosyal ağlarda paylaş

×
×
  • Yeni Oluştur...