Cast to ObjectId failed for value on findById [closed]What's Mongoose error Cast to ObjectId failed for value XXX at path “_id”?Find document with array that contains a specific valueHow to resolve Mongoose Connect UNKNOWN?Why this error coming while running nodejs server?Angular client-side image upload into JSON document and saved to mongo through node/expressPUT/ update operation fails in $resource AngularJS client in rest based app (mongoose insert / update issue).“Cannot GET /db/read/getall” accessing node.js express API using reverse proxy nginx on digitalocean dropletMongoose pre.remove middleware of objects in array are never calledWhy express.Router() while separating routesHow to send github OAuth data to client?

On studying Computer Science vs. Software Engineering to become a proficient coder

What does this quote in Small Gods refer to?

How can a Lich look like a human without magic?

Is a diamond sword feasible?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?

How are one-time password generators like Google Authenticator different from having two passwords?

What did Rocket give Hawkeye in "Avengers: Endgame"?

Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?

How can I answer high-school writing prompts without sounding weird and fake?

LocalDate.plus Incorrect Answer

"Fīliolō me auctum scito, salva Terentia"; what is "me" role in this phrase?

Why does a C.D.F need to be right-continuous?

51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?

Is there a faster way to calculate Abs[z]^2 numerically?

What are some possible reasons that a father's name is missing from a birth certificate - England?

Why can't RGB or bicolour LEDs produce a decent yellow?

What is the significance of 4200 BCE in context of farming replacing foraging in Europe?

What is the best way for a skeleton to impersonate human without using magic?

On what legal basis did the UK remove the 'European Union' from its passport?

We are two immediate neighbors who forged our own powers to form concatenated relationship. Who are we?

How to pronounce "r" after a "g"?

Is it a Munchausen Number?

How to make the table in the figure in LaTeX?



Cast to ObjectId failed for value on findById [closed]


What's Mongoose error Cast to ObjectId failed for value XXX at path “_id”?Find document with array that contains a specific valueHow to resolve Mongoose Connect UNKNOWN?Why this error coming while running nodejs server?Angular client-side image upload into JSON document and saved to mongo through node/expressPUT/ update operation fails in $resource AngularJS client in rest based app (mongoose insert / update issue).“Cannot GET /db/read/getall” accessing node.js express API using reverse proxy nginx on digitalocean dropletMongoose pre.remove middleware of objects in array are never calledWhy express.Router() while separating routesHow to send github OAuth data to client?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to get a single item from Mongodb, Mongoose with the code below. In Postman make a get request with an Id to
http://localhost:5000/api/report/l5c959036c3dfe2338412be8e and the error returned is




"message": "Cast to ObjectId failed for value
"l5c959036c3dfe2338412be8e" at path "_id" for model "Report




const express = require("express");
const app = express();
const mongoose = require("mongoose");
const cors = require("cors");
const bodyParser = require("body-parser");

mongoose.connect(
"mongodb://localhost:27017/reports",
useNewUrlParser: true, useCreateIndex: true
);
mongoose.connection.on(
"error",
console.error.bind(console, "connection error:")
);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded( extended: true ));
app.use(cors());

app.get("/api/report/:id", (req, res) =>
Report.findById(req.params.id, (err, report) =>
if (err) return res.status(404).send( message: err.message );
return res.send( report );
);
);


thanks for any help!










share|improve this question













closed as off-topic by Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao Mar 23 at 12:03


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao
If this question can be reworded to fit the rules in the help center, please edit the question.
















  • l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

    – Anthony Winzlet
    Mar 23 at 10:51












  • Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

    – Neil Lunn
    Mar 23 at 10:52

















0















I am trying to get a single item from Mongodb, Mongoose with the code below. In Postman make a get request with an Id to
http://localhost:5000/api/report/l5c959036c3dfe2338412be8e and the error returned is




"message": "Cast to ObjectId failed for value
"l5c959036c3dfe2338412be8e" at path "_id" for model "Report




const express = require("express");
const app = express();
const mongoose = require("mongoose");
const cors = require("cors");
const bodyParser = require("body-parser");

mongoose.connect(
"mongodb://localhost:27017/reports",
useNewUrlParser: true, useCreateIndex: true
);
mongoose.connection.on(
"error",
console.error.bind(console, "connection error:")
);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded( extended: true ));
app.use(cors());

app.get("/api/report/:id", (req, res) =>
Report.findById(req.params.id, (err, report) =>
if (err) return res.status(404).send( message: err.message );
return res.send( report );
);
);


thanks for any help!










share|improve this question













closed as off-topic by Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao Mar 23 at 12:03


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao
If this question can be reworded to fit the rules in the help center, please edit the question.
















  • l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

    – Anthony Winzlet
    Mar 23 at 10:51












  • Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

    – Neil Lunn
    Mar 23 at 10:52













0












0








0








I am trying to get a single item from Mongodb, Mongoose with the code below. In Postman make a get request with an Id to
http://localhost:5000/api/report/l5c959036c3dfe2338412be8e and the error returned is




"message": "Cast to ObjectId failed for value
"l5c959036c3dfe2338412be8e" at path "_id" for model "Report




const express = require("express");
const app = express();
const mongoose = require("mongoose");
const cors = require("cors");
const bodyParser = require("body-parser");

mongoose.connect(
"mongodb://localhost:27017/reports",
useNewUrlParser: true, useCreateIndex: true
);
mongoose.connection.on(
"error",
console.error.bind(console, "connection error:")
);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded( extended: true ));
app.use(cors());

app.get("/api/report/:id", (req, res) =>
Report.findById(req.params.id, (err, report) =>
if (err) return res.status(404).send( message: err.message );
return res.send( report );
);
);


thanks for any help!










share|improve this question














I am trying to get a single item from Mongodb, Mongoose with the code below. In Postman make a get request with an Id to
http://localhost:5000/api/report/l5c959036c3dfe2338412be8e and the error returned is




"message": "Cast to ObjectId failed for value
"l5c959036c3dfe2338412be8e" at path "_id" for model "Report




const express = require("express");
const app = express();
const mongoose = require("mongoose");
const cors = require("cors");
const bodyParser = require("body-parser");

mongoose.connect(
"mongodb://localhost:27017/reports",
useNewUrlParser: true, useCreateIndex: true
);
mongoose.connection.on(
"error",
console.error.bind(console, "connection error:")
);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded( extended: true ));
app.use(cors());

app.get("/api/report/:id", (req, res) =>
Report.findById(req.params.id, (err, report) =>
if (err) return res.status(404).send( message: err.message );
return res.send( report );
);
);


thanks for any help!







node.js mongodb mongoose






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 10:44









GosmithGosmith

606




606




closed as off-topic by Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao Mar 23 at 12:03


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao
If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao Mar 23 at 12:03


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Neil Lunn, Anthony Winzlet, chridam, Bhargav Rao
If this question can be reworded to fit the rules in the help center, please edit the question.












  • l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

    – Anthony Winzlet
    Mar 23 at 10:51












  • Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

    – Neil Lunn
    Mar 23 at 10:52

















  • l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

    – Anthony Winzlet
    Mar 23 at 10:51












  • Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

    – Neil Lunn
    Mar 23 at 10:52
















l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

– Anthony Winzlet
Mar 23 at 10:51






l5c959036c3dfe2338412be8e is not a valid objectId. Remove the l from the begning of the id.

– Anthony Winzlet
Mar 23 at 10:51














Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

– Neil Lunn
Mar 23 at 10:52





Means what it says. l5c959036c3dfe2338412be8e is not valid for an ObjectId value. 5c959036c3dfe2338412be8e without the "l" on the beginning is however valid. I suggest a typo.

– Neil Lunn
Mar 23 at 10:52












1 Answer
1






active

oldest

votes


















0














Try removing the "I" from the objectId you pass as the param, as suggested in the comments.






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try removing the "I" from the objectId you pass as the param, as suggested in the comments.






    share|improve this answer



























      0














      Try removing the "I" from the objectId you pass as the param, as suggested in the comments.






      share|improve this answer

























        0












        0








        0







        Try removing the "I" from the objectId you pass as the param, as suggested in the comments.






        share|improve this answer













        Try removing the "I" from the objectId you pass as the param, as suggested in the comments.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 11:46









        Moad EnnagiMoad Ennagi

        47048




        47048















            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현