I am trying to create a topic post when students complete an action. I am getting the dreaded Stat

Answers
-
Many thanks Judy
-
Hi @Judy Botejue - has there been any light shed on this? Thanks.
-
Again... any feedback would be appreciated... @Judy Botejue
-
Hi Bjorn,
Can you try removing the JSON.stringify( ) since you already have the body as string? I tested the body and route pattern and it works locally.
Thanks,
Richard
-
Hi Richard,
I'm afraid that still returns the same result. I've tried building the data as a JS object as well and passing it as I thought it might be that. The data looks like it matches the "CreatePostData" structure, but it is still being rejected. I am attaching a screenshot with a console log of the input and returns. The two "error" returns after the XHR status are just internal debugs. Thanks.
-
Just incase anyone else is looking at this, I think Bjorn and I figured out the issue. By default, the ajax post method is setting the Content-Type header to 'application/x-www-form-urlencoded'. The content type header must be set to 'application/json'.
-
Thank you Richard! It now works great!
For those interested, the code now looks like this :
$.ajax({
url: sendURL,
type: 'POST',
data: JSON.stringify(postString),
headers: {
'X-CSRF-TOKEN':localStorage.getItem("XSRF.Token"),
'Content-Type':'application/json'
},
Categories
- All Categories
- 6 Thought Leadership
- 7 Known and Fixed Issues
- 6 Product Roadmap
- 553 Archived
- 10 Accessibility
- 28 Community Corner
- 2 Welcome
- Updates
- Member Spotlights
- 4 Events
- 242 Development
- 746 Customer Enablement
- Evaluate - Assess Student Learning
- Get Comfortable with Brightspace
- Communicate - Engage with Your Students
- 1 Create - Set up your Brightspace course
- Action - Add or create student activities
- 26 Partners
- 8 Product News
- 2022
- 2022 Release Notes
- 2021 Release Notes
- 4 Training
- andycat