Closed (won't fix)
Project:
Services
Version:
7.x-3.0-rc5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Nov 2011 at 22:25 UTC
Updated:
4 Apr 2012 at 18:17 UTC
I'm doing a basic jQuery ajax post to a targeted action. Each time it generates a notice.
Here's the jQuery ajax:
$(function(){
$('#greet').click(function(e){
e.preventDefault();
var name = $('#name');
$.ajax({
url: '/webservice/greetings/' + name.val() + '/sayhello',
type: 'post',
dataType: 'json',
success: function(message){
alert(message);
}
});
});
});
Here's the notice:
340 21/Nov 16:13 notice php Notice: Undefined index: CONTENT_TYPE in RESTServer->parseRequest() (line 261 of /home/ry/sites/dev/sites/all/modules/contrib/services/servers/rest_server/includes/RESTServer.inc).
Apparently $_SERVER['CONTENT_TYPE'] is not being set for some reason.
Comments
Comment #1
marcingy commentedYou should be setting that header when you post the data. And why are you using rc5?
Comment #2
rylowry@gmail.com commentedIf I add an empty data object, the notice disappears. My guess is that my first ajax post did not result in a request with a body, so there was no $_SERVER['CONTENT_TYPE']. It seems to me that posting to a targeted action without any body seems like it shouldn't generate a notice.
Comment #3
rylowry@gmail.com commentedI'm on rc5 because we don't immediately update to the latest version of our modules. We upgrade modules periodically. We happen to be on the version I mentioned in the report when I saw this notice.
Comment #4
marcingy commentedThere should be content type being provided to the server, this is really a won't fix or if there is a bug it is upstream of services.
Comment #5
rylowry@gmail.com commentedI added
contentType: 'application/json',
That forces the header to be there even if the body is empty, which makes services happy. Thanks.
Comment #6
aspilicious commentedIn deploy => plugins => DeployServiceRestJSON.inc the content_type got set.
$this->config['headers']['Content-Type'] = 'application/json';I wonder why that is put inside the foreach...
Should also work outside of it, normaly...
Maybe it has to be contentType or CONTENT_TYPE or Content_Type...
You should try one of those.
Comment #7
aspilicious commentedwrong issue