Making an HTTP POST (REST API) using a microcontroller / plaintext pre-encoded POST strings

Solution for Making an HTTP POST (REST API) using a microcontroller / plaintext pre-encoded POST strings
is Given Below:

I’m working on a project where a microcontroller interfaces to a web server. It’s fairly close to bare metal, so no libraries or what have you are allowed for this project.

I’ve been able to do GET requests just fine, encoding the strings for my micro like this:

"GET /rest/foo/_attribute/bar/ HTTP/1.1rnrn"

with the data being returned looking something like this:

HTTP/1.1 200 OK                                                               
Date: Thu, 01 Jan 1970 00:01:06 GMT                                           
Connection: Keep-Alive                                                        
Set-Cookie: rtlt4session=1; path=/                                            
Cache-control: no-cache                                                       
Content-Type: application/json                                                
Content-Length: 70
                                                                    
{"bar":"factory":"Attribute","factoryType":"bool","value":true}}`

However, I’m having issues with making POST requests. I’ve tried this:

"POST /rest/foo/_attribute/bar/ HTTP/1.1rnrn{"bar":"factory":"Attribute","factoryType":"bool","value":false}}rnrn"

but it doesn’t work properly, with the device usually waiting a while then responding with a 400 Bad Request message, stating that the REST update content is missing, as shown below:

HTTP/1.1 400 Bad Request                                    
Date: Thu, 01 Jan 1970 00:07:23 GMT                         
Connection: Keep-Alive                                      
Set-Cookie: rtlt4session=3; path=/                          
Cache-control: no-cache                                     
Content-Type: text/plain                                    
Content-Length: 84
                                                                                                                        
Missing REST update content on a POST for REST URI '/rest/foo/_attribute/bar'

Any suggestions or advice would be greatly appreciated.