<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>HTTPS POST request connect failing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64542/https-post-request-connect-failing</link><description>Hi, 
 I am working on changing my GET request to a POST request and am failing at the connect() function, which makes me think I have the wrong header. There seem to be multiple examples out there, and all of them different. Can someone check my code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Aug 2020 10:50:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64542/https-post-request-connect-failing" /><item><title>RE: HTTPS POST request connect failing</title><link>https://devzone.nordicsemi.com/thread/263572?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2020 10:50:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a9a30f3-7571-407b-9f9c-0239dfd3363e</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="kgarland789"]What header file is EOPNOTSUPP defined in?[/quote]
&lt;p&gt;The error code is given in &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/896b8d3c50eb857f070b631a218154710163b5db/lib/libc/minimal/include/errno.h#L81"&gt;errno.h&lt;/a&gt; following&amp;nbsp;&lt;a href="https://man7.org/linux/man-pages/man3/errno.3.html"&gt;https://man7.org/linux/man-pages/man3/errno.3.html&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
[quote user="kgarland789"]Is there a better way to send a payload over https post?[/quote]
&lt;p&gt;&amp;nbsp;HTTPS Client sample uses TLS. In this sample, the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/16fcee7bce46541e8cce2d035eb926c3f7a2162f/samples/nrf9160/https_client/src/main.c#L130-L138"&gt;TLS_setup()&lt;/a&gt; associates a socket with the security tag that the samples provisions the certificate with.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The server you are using does most likely have a certificate that you must use, however, it may return a certificate that is too large for the TLS buffer to handle, which is currently 2kB (maximum).&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I recommend talking to your IT department to clarify what is needed to communicate with the server and to check what the &lt;a href="https://www.cloudflare.com/learning/ssl/what-happens-in-a-tls-handshake/"&gt;TLS handshake&lt;/a&gt;&amp;nbsp;looks like&amp;nbsp;in regards to certificates returned by the server to the client.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HTTPS POST request connect failing</title><link>https://devzone.nordicsemi.com/thread/263493?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 18:19:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:109714a4-ef6c-4809-882b-5e99ca3b4dee</guid><dc:creator>kgarland789</dc:creator><description>&lt;p&gt;Hi &amp;Oslash;yvind,&lt;/p&gt;
&lt;p&gt;Thanks for your response.&lt;/p&gt;
&lt;p&gt;The certificate is working when I attempt to connect to google.com, but I was told we don&amp;#39;t need a certificate to connect to our webserver (I am not skilled in backend webdev stuff). What header file is EOPNOTSUPP defined in?&lt;br /&gt;&lt;br /&gt;At the end of the day yesterday, I was able to get the POST request working using the url below, but now I am unable to get it working again today.&lt;/p&gt;
&lt;p&gt;char send_buf[] = &amp;quot;POST /api? HTTP/1.1\r\nHost: myserver.com\r\nConnection: keep-alive\r\nContent-type: application/json\r\nContent-length: 41\r\n\r\n\{\&amp;quot;product_id\&amp;quot;: \&amp;quot;xxxxxxxxx\&amp;quot;\}&amp;quot;;&lt;/p&gt;
&lt;p&gt;Is there a better way to send a payload over https post? It seems a bit much to confgure for JSON and send in the request header. I can&amp;#39;t seem to find any examples on how to send the payload.&lt;/p&gt;
&lt;p&gt;I am using the latest version of ncs v 1.3? And also the latest version of modem firmware 2020-04-29_bc7ade8b&lt;/p&gt;
&lt;p&gt;Thanks for your assistance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HTTPS POST request connect failing</title><link>https://devzone.nordicsemi.com/thread/263414?ContentTypeID=1</link><pubDate>Thu, 06 Aug 2020 11:37:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee3f622d-ea8a-451e-8335-1074626ef0de</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Have you verified that the certificate is correct? Often you will see that errno 45 is returned if the certificate is not correct.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define EOPNOTSUPP 45      /* Operation not supported on socket */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What version of NCS and modem FW are you running?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>