title: Update Infopath Form Library values through rest api or jsom?
body: <p>Is it possible to update infopath form library field values programmatically either through rest api or JSOM? If so can you provide a sample?</p>
  <p>I've tried it both ways, and both times I'm getting success messages although the moment I review the form I just attempted to update the values remain the same.</p>
  <pre><code>&lt;script&gt;
    
      //Retrieve list items from sharepoint using API  
      function GetSampleListItems() {  
          siteURL = _spPageContextInfo.webAbsoluteUrl;  
          console.log(&quot;from top nav - &quot; + siteURL);  
          var apiPath = _spPageContextInfo.webAbsoluteUrl +&quot;/_api/lists/getbytitle('Training%20Copy')/items/getbyid(9)&quot;;  
          $.ajax({  
                  url: apiPath,  
                  type: &quot;POST&quot;,  
                  headers: {  
                      Accept: &quot;application/json;odata=verbose&quot;  
                  },  
                  data: JSON.stringify
                  ({
                      __metadata:
                      {
                          type: &quot;SP.Data.Training_x0020_CopyItem&quot;
                      },
                      Position: &quot;Show&quot;
                  }), 
                  headers: {  
                  &quot;Accept&quot;: &quot;application/json;odata=verbose&quot;,
                  &quot;Content-Type&quot;: &quot;application/json;odata=verbose&quot;,
                  &quot;X-RequestDigest&quot;: $(&quot;#__REQUESTDIGEST&quot;).val(),
                  &quot;IF-MATCH&quot;: &quot;*&quot;,  
                  &quot;X-HTTP-Method&quot;: &quot;MERGE&quot; 
              }, 
              async: false, success: function(data) {  
                  alert(&quot;Item updated successfully&quot;);  
              }, eror: function(data) {  
                  console.log(&quot;An error occurred. Please try again.&quot;);  
              }
          })   
      
      }
  &lt;/script&gt;
  
  &lt;button onclick=&quot;GetSampleListItems();&quot; type=&quot;button&quot;&gt;Click me​&lt;/button&gt;
  
  </code></pre>