<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ curl - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ curl - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Wed, 24 Jun 2026 22:47:42 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/curl/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ REST API cURL Post Request via Construct 3 GameDev Tool & AJAX Module ]]>
                </title>
                <description>
                    <![CDATA[ By Andreas Lopez Hello FreeCodeCamp Reader Community! This Tutorial is made as a little thought experiment but might have some merit for the one or other person. Please keep in mind that this plugin is making an example by adding a product via Const... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/rest-api-curl-post-request-via-construct-3-gamedev-tool-ajax-module/</link>
                <guid isPermaLink="false">66d45d99d62e921b49e02cb6</guid>
                
                    <category>
                        <![CDATA[ construct 3 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ajax ]]>
                    </category>
                
                    <category>
                        <![CDATA[ curl ]]>
                    </category>
                
                    <category>
                        <![CDATA[ json ]]>
                    </category>
                
                    <category>
                        <![CDATA[ REST API ]]>
                    </category>
                
                    <category>
                        <![CDATA[ woocommerce ]]>
                    </category>
                
                    <category>
                        <![CDATA[ WordPress ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 23 Jun 2019 02:25:54 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/06/c3-woo-wp-banner.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Andreas Lopez</p>
<p>Hello FreeCodeCamp Reader Community! This Tutorial is made as a little thought experiment but might have some merit for the one or other person.</p>
<blockquote>
<p>Please keep in mind that this plugin is making an example by adding a product via Construct 3 Forms + REST API cURL Request to an existing WordPress + WooCommerce installation.</p>
</blockquote>
<p>The principles still are valid for other purposes you might have with the REST API, and I included the .c3p on the bottom of this tutorial. There are more elegant ways about feeding the arrays of information to the application, but this is a quick demo as proof-of-concept that I put together within 2 hours and felt like sharing it due to the lack of API and AJAX information for Construct 3.</p>
<p><strong>Here is the entire code in a single screenshot:</strong></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/06/c3-api-example.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Construct 3 Source Code Screenshot</em></p>
<h1 id="heading-the-code-broken-down-once-we-click-on-create-product-button">The Code Broken Down once we click on 'Create Product' button</h1>
<ul>
<li>productjson is an obligatory text field outside of the viewport on the layout.</li>
<li>productjson contains our entire payload data pre-formatted as json to allow the REST API to work properly.</li>
<li>The payload contains dynamically created content which are the forms in the layout such as product name, sku, price, etc.</li>
<li>The AJAX module that I renamed AJAX_Data will set the Request_Header to "Content-Type" with the value of "application/json", because the REST API via cURL request will utilize JSON.</li>
<li>The next AJAX_Data with the 'Post to URL' request will be our actual API request.</li>
<li>The Tag is merely a name which can be utilized for example to return the values of the request, in the example of my project - as debugging information.</li>
<li>The URL will start with your domain, i.e. 'https://www.example.com' The next part of the URL is the API request you would like to make, in our example as per WooCommerce documentation to add a product we need '/wp-json/wc/v3/products?'</li>
<li>Last but not least for the URL we need the consumer key and secret in this manner: 'consumer_key=&amp;consumer_secret='</li>
<li>The full URL looks like this: "https://www.example.com/wp-json/wc/v3/products?consumer_key=&amp;consumer_secret="</li>
<li>Next up is the Data. This is simple since we already have made a text box for this exact purpose. Simply refer to it here, in my example the Data will be 'productjson.Text'.</li>
<li>And at the very end, what type of Request. Since we are creating a product we will need 'POST', if we were to retrieve a product we would want a 'GET' request, see the respective documentation of the API you are using.</li>
</ul>
<h3 id="heading-c3p-file-download">.c3p File Download:</h3>
<p><a target="_blank" href="https://drive.google.com/open?id=16DKq5RJD5tCw57oZPruGk_mtTIAe-Um9%5B/url%5D">https://drive.google.com/open?id=16DKq5RJD5tCw57oZPruGk_mtTIAe-Um9</a></p>
<h1 id="heading-requirements-for-my-c3p-example">Requirements for my .c3p example</h1>
<ul>
<li>WordPress Installation with WooCommerce installed</li>
<li>REST API enabled and issued a consumer secret &amp; key</li>
<li>Replace my API secret and key example in the code</li>
<li>Uploaded an image in the media gallery within WordPress</li>
<li>Created a Product Category within WordPress/WooCommerce</li>
</ul>
<p>If you need a free WordPress environment to play around with, I used <a target="_blank" href="https://pantheon.io">https://pantheon.io</a>, under the free plan you can get 2 sandbox sites. Just make sure to install the WP-CORS plugin first and set allowed sites to '*' as seen in their documentation here:<br><a target="_blank" href="https://pantheon.io/docs/platform-considerations/#cors%5B/url%5D">https://pantheon.io/docs/platform-considerations/#cors</a></p>
<p><a target="_blank" href="https://wordpress.org/plugins/wp-cors/%5B/url%5D">https://wordpress.org/plugins/wp-cors/</a></p>
<h3 id="heading-api-source-information-amp-relevant-c3-documentation">API Source Information &amp; Relevant C3 Documentation:</h3>
<p><a target="_blank" href="https://woocommerce.github.io/woocommerce-rest-api-docs">WooCommerce REST API Documentation</a><br><a target="_blank" href="https://www.construct.net/en/make-games/manuals/construct-3/plugin-reference/ajax">Construct 3 AJAX Documentation</a><br><a target="_blank" href="https://jsonlint.com/">JSON Validator tool to verify if your JSON is properly formatted.</a><br><a target="_blank" href="https://www.construct.net/en/tutorials/rest-api-curl-post-request-2245">Original Tutorial I wrote on Construct.net</a></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
