codeclannigeria/codeclannigeria-backend

Can't create a task still

Closed this issue · 3 comments

Describe the bug
I tried to create a task with the JSON below
{ "deadline": "2020-09-2", "title": "Learn how the internet works", "description": "Topic: The Internet<br> <br> Video Resources<br> <br> https://www.youtube.com/watch?v=Dxcc6ycZ73M&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=2&t=0s<br> <br> https://www.youtube.com/watch?v=ZhEf7e4kopM&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=3&t=0s<br> <br> https://www.youtube.com/watch?v=5o8CwafCxnU&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=4&t=0s<br> <br> https://www.youtube.com/watch?v=AYdF7b3nMto&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=5&t=0s<br> <br> https://www.youtube.com/watch?v=kBXQZMmiA4s&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=6&t=0s<br> <br> https://www.youtube.com/watch?v=ZghMPWGXexs&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=7&t=0s<br> <br> https://www.youtube.com/watch?v=AuYNXgO_f3Y&list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&index=8&t=0s<br> <br> <br> <br> Task:<br> <br> Write an Article on What you have learnt so far. Does the Internet fascinate or intrigue you. One of the best ways to learn about a thing is to write about it.<br> <br> Submission Guideline<br> <br> Create a blog on hashnode.com then post your article on it. Submit with a link to the article.", "track": "5f4594faf58e03001790cfb4", "stage": "5f459564f58e03001790cfb7", "course": "string" }

To Reproduce
Try the JSON on swagger

Expected behavior
I should be able to pass in HTML codes and store to the server. We want to display formatted text to the user.

Hi @tayormi
Try to escape the string first.

Please close this issue if that resolves it

@ofuochi, after escpaing the HTML string, I get the error below.
{ "message": [ "description must be shorter than or equal to 1024 characters", "course must be a mongodb id" ], "error": "Bad Request", "stack": null, "errors": null, "path": "/tasks", "timestamp": "2020-08-26T15:28:47.556Z", "statusCode": 400, "status": "BAD_REQUEST" }

1024 characters is too small. Take the task as a blog post.

Also, a task may not have a course. It's optional.

Here is a sample of the JSON I am trying to pass.
{ "deadline": "2020-09-2", "title": "Learn how the internet works", "description": "&lt;p&gt;&lt;strong&gt;Topic&lt;/strong&gt;:&lt;span&gt;The&nbsp;Internet&lt;/span&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;Video&nbsp;Resources&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=Dxcc6ycZ73M&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=2&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=Dxcc6ycZ73M&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=2&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=ZhEf7e4kopM&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=3&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=ZhEf7e4kopM&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=3&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=5o8CwafCxnU&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=4&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=5o8CwafCxnU&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=4&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=AYdF7b3nMto&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=5&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=AYdF7b3nMto&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=5&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=kBXQZMmiA4s&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=6&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=kBXQZMmiA4s&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=6&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=ZghMPWGXexs&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=7&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=ZghMPWGXexs&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=7&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;&lt;a&nbsp;href=&quot;https://www.youtube.com/watch?v=AuYNXgO_f3Y&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=8&amp;amp;t=0s&quot;&gt;https://www.youtube.com/watch?v=AuYNXgO_f3Y&amp;amp;list=PLkZYeFmDuaN21nQjzE4RLLNccK_YP0P0_&amp;amp;index=8&amp;amp;t=0s&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;strong&gt;Task:&lt;/strong&gt;&lt;/p&gt;<br/>&lt;p&gt;&lt;span&gt;Write&nbsp;an&nbsp;Article&nbsp;on&nbsp;What&nbsp;you&nbsp;have&nbsp;learnt&nbsp;so&nbsp;far.&nbsp;Does&nbsp;the&nbsp;Internet&nbsp;fascinate&nbsp;or&nbsp;intrigue&nbsp;you.&nbsp;One&nbsp;of&nbsp;the&nbsp;best&nbsp;ways&nbsp;to&nbsp;learn&nbsp;about&nbsp;a&nbsp;thing&nbsp;is&nbsp;to&nbsp;write&nbsp;about&nbsp;it.&lt;/span&gt;&lt;br&nbsp;/&gt;&lt;br&nbsp;/&gt;&lt;span&gt;&lt;strong&gt;Submission&nbsp;Guideline&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;<br/>&lt;p&gt;Create&nbsp;a&nbsp;blog&nbsp;on&lt;a&nbsp;href=&quot;https://hashnode.com/&quot;&gt;hashnode.com&lt;/a&gt;then&nbsp;post&nbsp;your&nbsp;article&nbsp;on&nbsp;it.&nbsp;Submit&nbsp;with&nbsp;a&nbsp;link&nbsp;to&nbsp;the&nbsp;article.&lt;/p&gt;<br/>&lt;p&gt;The&nbsp;&lt;a&nbsp;target=&quot;_blank&quot;&nbsp;href=&quot;https://html-cleaner.com/css/&quot;&nbsp;rel=&quot;noopener&quot;&gt;online&nbsp;HTML&nbsp;and&nbsp;CSS&nbsp;cleaner&lt;/a&gt;&nbsp;will&nbsp;take&nbsp;care&nbsp;of&nbsp;your&nbsp;dirty&nbsp;markup.&nbsp;They&nbsp;are&nbsp;free&nbsp;online&nbsp;tools.&lt;/p&gt;", "track": "5f4594faf58e03001790cfb4", "stage": "5f459564f58e03001790cfb7", "course": "string" }