0 Replies Latest reply: Jun 20, 2012 8:52 AM by Rob Galvin RSS

    REST Create Document returning "Missing Body"

    Rob Galvin

      I am using version 5.03 REST Services to created/update documents. I am using Ruby's Rest-Client for the REST requests. On some of my requests to do a PUT for document update, I am getting response:

       

      {
        "message" : "Missing body",
        "code" : 4045
      }
      

       

      So it looks like something in my JSON body is not valid, but for the life of me I can't figure it out. I run it through JSONLint validator and it does not complain. To create the JSON, I am initially created a Ruby hash

       

      request_body = {:subject => subject, :content => {:type => "text/html", :text => body}}
      
      

      and then converting it to json:

       

      @json_body = request_body.to_json
      
      

       

      Here is my json body:

       

      {"subject":"EmmlProfile Module","content":{"type":"text/html","text":"<div class=\"rhodocs\"><div id=\"title\" style=\"display:none\">EmmlProfile Module</div>\n\n<p><span class=\"label label-info\">HTML</span> <span class=\"label label-warning\">JAVASCRIPT</span> <span class=\"label label-important\">RUBY</span> <span class=\"label label-inverse\">RHOELEMENTS</span></p>\n\n<p><b>\nThe EmmlProfile Module is used to manage EMML profile pages.\n</b></p>\n\n<a name=\"syntax\"></a><ul id=\"toc\"><li><a href='#syntax'>Syntax</a></li><li><a href='#parameters'>Parameters</a></li><li><a href='#remarks'>Remarks</a></li><li><a href='#htmljavascript-examples'>HTML/Javascript Examples</a></li></ul><h2>Syntax</h2>\n\n<table class=\"re-table\"><tr><th class=\"tableHeading\">emmlProfile (Module) &lt;META&gt; Syntax\n</th></tr><tr><td class=\"clsSyntaxCells clsOddRow\"><p>&lt;META HTTP-Equiv=\"EMMLProfile\" content=\"parameter:value\"&gt;</p></td></tr></table>\n\n\n<table class=\"re-table\"><tr><th class=\"tableHeading\">EmmlProfile JavaScript Object Syntax:</th></tr><tr><td class=\"clsSyntaxCells clsOddRow\">\nBy default the JavaScript Object <b>'emmlProfile'</b> will exist on the current page and can be used to interact directly with the emmlProfile.\n</td></tr><tr><td class=\"clsSyntaxCells clsEvenRow\">\nTo Set emmlProfile parameters via JavaScript use the following syntax: emmlprofile.parameter = 'value'; remembering to enclose your value in quotes where appropriate.  \n<P />e.g. <b>emmlProfile</b>.name = 'value';\n</td></tr><tr><td class=\"clsSyntaxCells clsOddRow\">                         \nTo set multiple <a href=\"../Resources/../Getting Started/EMMLOverview.html\">EMML</a> parameters / events on a single line use the following syntax: emmlprofile.setEMML(\"[Your EMML Tags]\");\n<P />\ne.g. <b>emmlProfile</b>.setEMML(\"name:<i>value</i>\");                           \n</td></tr></table>\n\n\n\n\n<table class=\"re-table\"><tr><th class=\"tableHeading\">EmmlProfile Ruby Object Syntax:</th></tr><tr><td class=\"clsSyntaxCells clsOddRow\">\nBy default the Ruby Object <b>'EmmlProfile'</b> will exist on the current page and can be used to interact directly with the EmmlProfile. All Methods, Parameters and Events are the same as Javascript, however, notice <b>'EmmlProfile'</b> needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in <b>'()'</b></td></tr><tr><td class=\"clsSyntaxCells clsEvenRow\">\nTo Set EmmlProfile parameters via Ruby use the following syntax: EmmlProfile.parameter = 'value' remembering to enclose your value in quotes where appropriate.  \n<P />e.g. <b>EmmlProfile</b>.name = 'value'\n</td></tr><tr><td class=\"clsSyntaxCells clsOddRow\" /></tr></table>\n\n\n<a name=\"parameters\"></a><h2>Parameters</h2>\n\n<p>Items listed in this section indicate parameters, or attributes which can be set.</p>\n\n<table class=\"re-table\"><col width=\"20%\" /><col width=\"20%\" /><col width=\"38%\" /><col width=\"22%\" /><tr><th class=\"tableHeading\">Name</th><th class=\"tableHeading\">Possible Values</th><th class=\"tableHeading\">Description</th><th class=\"tableHeading\">Default Value</th></tr><tr><td class=\"clsSyntaxCells clsOddRow\"><b>name:[Value]\n</b></td><td class=\"clsSyntaxCells clsOddRow\">[optional name] (see remarks below)</td><td class=\"clsSyntaxCells clsOddRow\">Imports the EMML profile page stored at the local specified by \"import\". Nb. This parameter should come before the related import method.</td><td class=\"clsSyntaxCells clsOddRow\">N/A</td></tr><tr><td class=\"clsSyntaxCells clsEvenRow\"><b>importProfile:[Value]\n</b></td><td class=\"clsSyntaxCells clsEvenRow\">url('URI')</td><td class=\"clsSyntaxCells clsEvenRow\">http or file location of the .emmp file containing the EMML profiles to be imported.</td><td class=\"clsSyntaxCells clsEvenRow\">N/A</td></tr><tr><td class=\"clsSyntaxCells clsOddRow\"><b>clear:[Value]\n</b></td><td class=\"clsSyntaxCells clsOddRow\">[optional name] (see remarks below)</td><td class=\"clsSyntaxCells clsOddRow\">Clears the currently loaded EMML profiles.</td><td class=\"clsSyntaxCells clsOddRow\">N/A</td></tr><tr><td class=\"clsSyntaxCells clsEvenRow\"><b>apply:[Value]\n</b></td><td class=\"clsSyntaxCells clsEvenRow\">[profile class name]</td><td class=\"clsSyntaxCells clsEvenRow\">Applies the EMML profile with the class name specified. </td><td class=\"clsSyntaxCells clsEvenRow\">N/A</td></tr></table>\n\n\n<table class=\"re-table\"><col width=\"78%\" /><col width=\"8%\" /><col width=\"1%\" /><col width=\"5%\" /><col width=\"1%\" /><col width=\"5%\" /><col width=\"2%\" /></table>\n\n\n<a name=\"remarks\"></a><h2>Remarks</h2>\n\n<h3>Named Profile Pages</h3>\n\n<p>Normally, when importing a profile page, the imported profiles will be cleared from memory when the page is navigated away from. If you provide a name when importing a profile page, the imported profiles will not be cleared on page navigation and you will be able to reference them until you manually clear the profiles. To reference a named imported profile, prefix the profile class name with the name you supplied when importing the profile page (see example above). Naming profile pages can improve performance. If you include many profiles for your application within the profile page, it will only have to be downloaded, parsed and imported the once. It is often also preferable to maintain a central location for all your EMML.</p>\n\n<h3>Importing Local Profiles</h3>\n\n<p>Importing profiles from a file:// location will cause the profile to be moved from its previous location, not copied.</p>\n\n<table class=\"re-table\"><tr><th class=\"tableHeading\">Supported Devices</th><td class=\"clsSyntaxCell clsOddRow\">All supported devices.</td></tr><tr><th class=\"tableHeading\">Persistence</th><td class=\"clsSyntaxCell clsEvenRow\">Partially Transient - any changes made by changing parameters will be lost when navigating to a new page with the exception of when a named EMML profile set is imported.</td></tr><tr><th class=\"tableHeading\">Minimum Requirements</th><td class=\"clsSyntaxCell clsOddRow\" /></tr></table>\n\n\n<a name=\"htmljavascript-examples\"></a><h2>HTML/Javascript Examples</h2>\n\n<p>The following example imports an EMML profile page into the temporary, unnamed space.\n<META HTTP-Equiv=\"EMMLProfile\" Content=\"import:url('http://myserver/scannerparams.emmp');\">\nThe following example imports an EMML profile page into a page persistent, named space.\n<META HTTP-Equiv=\"EMMLProfile\" Content=\"name:scanner_params;import:url('http://myserver/scannerparams.emmp');\">\nThe following example applies two profile classes from the temporary, unnamed space.\n<META HTTP-Equiv=\"EMMLProfile\" Content=\"apply:default_decoders;\"></p>\n\n<pre class=\"CodeRay\"><code>&lt;META HTTP-Equiv=\"EMMLProfile\" Content=\"apply:inventory_decoders;\"&gt;\n</code></pre>\n\n<p>The following example applies two profile classes from page persistent, named space.\n<META HTTP-Equiv=\"EMMLProfile\" Content=\"apply:scanner_params.default_decoders;\"></p>\n\n<pre class=\"CodeRay\"><code>&lt;META HTTP-Equiv=\"EMMLProfile\" Content=\"apply:scanner_params.inventory_decoders;\"&gt;\n</code></pre>\n\n<p>The following is an example of an EMML Profile page.\n.default_decoders</p>\n\n<pre class=\"CodeRay\"><code>{\n  scanner-all_decoders: disabled;\n  scanner-code128other128: false;\n  scanner-code128maxlength: 10;\n  scanner-code128minlength: 1;\n  scanner-code128: enabled;\n}\n\n.inventory_decoders\n{\n  scanner-ean13converttocode128: true;\n  scanner-ean13: enabled;\n  scanner-ean8: enabled;\n  scanner-i2of5: enabled;\n  scanner-code128: enabled;\n}\n</code></pre>\n</div>"}}