Axios cannot get WP Json from WordPress Headless CMS - wordpress

I have a JSON data which I want to get from my wordpress headless CMS site here.
const wpUrl = "https://jameslaiproductions.ml/wp-json/wp/v2/posts";
However, I received a network error when getting data from this url.
On the other hand, I am successful in getting data from any of the two url below:
const wpUrl = "https://test.frontity.org/wp-json/wp/v2/posts";
const wpUrl = "https://oncoinfo.it/wp-json/wp/v2/posts";
I suspect that the issue is with my WordPress or shared server hosting settings. But I can't seem to identify the problem & solution to this problem. Please refer to the sandbox link below to view the replicated problem.
https://codesandbox.io/s/epic-sanderson-zpm8n?file=/src/component/Test01.js

My webhost service provider (Infinity Free) has responded that this cannot work due to its security system. More info here.
Now moving on to my next question;
Is there any way to work around this? If yes, how?
Which free web hosting service provider is recommended for me to be able to retrieve data from WP-Json?

Related

Invalid Dynamic Link on accessing https://app.page.link (no query params)

Here is my Firebase Dynamic Links page:
On running this command: npx uri-scheme open "https://app.page.link" --android - notice there is no query params in the link, a web page is opened on Android as expected, but with the following content:
It is working find when I add /c8Ci or /bbb at the end, but it throws me the error above when the link is clear (without any query params)
To be short:
Android:
https://app.page.link/bbb - success (app launched)
https://app.page.link/c8Ci - success (app launched)
https://app.page.link - fail
iOS
https://app.page.link/bbb - success (app launched)
https://app.page.link/c8Ci - success (app launched)
https://app.page.link - success (app launched)
Can you please help me to figure out what's wrong with my Dynamic Linking.
Thank you mates in advance!
It is an expected behavior when you try to open the "https://app.page.link" directly, as its purpose is solely for Dynamic Links domain only. Note that Firebase provides a default 'page.link' subdomain for your Dynamic Links for free, this is because you can't use the same domain for both Dynamic Links and regular hosting. The domain is not configured to behave as a regular Hosting domain.
This is why configuring a short link URL allows you to redirect your users to you app. And visiting the domain directly returns an invalid page.
As for iOS, I can only assume it was cached that’s why it worked.
I guess it is best reaching out directly to Firebase support regarding this as there could be any other underlying reasons that could cause this.

Stuck with woocommerce_rest_authentication_error: Invalid signature - provided signature does not match

Below issue was posted by me on https://github.com/XiaoFaye/WooCommerce.NET/issues/414 but since this may not be related at all to WooCommerce.Net but on a lowerlevel to Apache/Word/WooCommerc itself I am posting the same question here
I am really stuck with the famous error:
WebException: {"code":"woocommerce_rest_authentication_error","message":"Invalid signature - provided signature does not match.","data":{"status":401}}
FYI:
I have two wordpress instance running. One on my local machine and one on a remote server. The remote server is, as my local machine, in our company's LAN
I am running WAMP on both machines to run Apache and host Wordpress on port 80
The error ONLY occurs when trying to call the Rest api on the remote server. Connecting to the local rest api, the Rest Api/WooCommerceNet is working like a charm :-)
From my local browser I can login to the remote WooCommerce instance without any problem
On the remote server I have defined WP_SITEURL as 'http://[ip address]/webshop/ and WP_HOME as 'http://[ip address]/webshopin wp-config.php
Calling the api url (http://[ip address]/webshop/wp-json/wc/v3/) from my local browser works OK. I get the normal JSON response
Authentication is done through the WooCommerce.Net wrapper which only requires a consumer key, consumer secret and the api url. I am sure I am using the right consumer key and secret and the proper api url http://[ip address]/webshop/wp-json/wc/v3/ (see previous bullet)
I already played around with the authorizedHeader variable (true/false) when instantiating a WooCommerce RestApi but this has no effect
Is there anybody that can point me into the direction of a solution?
Your help will be much appreciated!
In my case, the problem was in my url adress. The URL Adress had two // begin wp-json
Url Before the solution: http://localhost:8080/wordpress//wp-json/wc/v3/
URL Now, and works ok: http://localhost:8080/wordpress/wp-json/wc/v3/
I use with this sentence.
RestAPI rest = new RestAPI(cUrlApi, Funciones.CK, Funciones.CS,false);
WCObject wc = new WCObject(rest);
var lstWooCategorias = await wc.Category.GetAll();
I hope my answer helps you.
Had the same issue. My fault was to define my url incorrect: http:// instead of https://.

Why won't OAuth work on web server?

I have an ASP.Net web application running on Windows Server 2012, and need to make calls to social networking sites using oauth to generate some of the page content. Everything works on my development machine, but I can't even get a single response back ("unable to connect to the remote server" error).
I disabled the firewall to test that. No luck. I created a console application to test it that way. A simple HttpWebRequest will get the html for any page I throw at it, but not any oauth request. I've used different libraries to try to achieve this, including Linq2Twitter, Spring.Social, and HigLabo. All work locally, but not on the server. I've found nothing useful in the server event log.
Can anyone give me some clues what might be happening?
EDIT: Here's some code I'm using with the HigLabo library to try to retrieve the user timeline.
using HigLabo.Net.Twitter;
var cl = new TwitterClient(consumerKey, consumerSecret, accessToken, accessTokenSecret);
var rr = cl.GetHomeTimeline();
foreach (var r in rr)
{
//Console.WriteLine(r.CreatedAt + ":" + r.Text);
}
I'm aware that accessToken & accessTokenSecret aren't/shouldn't be necessary for a simple timeline read, but this is just to make sure it works first.
This turned out to be a firewall issue, as had been suspected. But not the server firewall. This was a problem with the ISP. They had an internal firewall that was blocking all traffic to/from the social network sites. They were able to resolve it quickly with a phonecall, but it was not a coding or configuration error on my part.

Basic HTTP Authentication with python 3.2 (urllib.request)

This is my first post with this account, and Ive been struggling for the last week to get this to work, so I hope someone can help me get this working.
Im trying to pull some data from https://api.connect2field.com/ but its rejecting all of my authentication attempts from python (not from a browser though).
The code Im using
import urllib.request as url
import urllib.error as urlerror
urlp = 'https://api.connect2field.com/api/Login.aspx'
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = url.HTTPBasicAuthHandler()
auth_handler.add_password(realm='Connect2Field API',
uri=urlp,
user='*****',
passwd='*****')
opener = url.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
url.install_opener(opener)
try:
f = url.urlopen(urlp)
print (f.read())
except urlerror.HTTPError as e:
if hasattr(e, 'code'):
if e.code != 401:
print ('We got another error')
print (e.code)
else:
print (e.headers)
Im pretty sure the code is doing everything right, which makes me think that maybe theres another authentication step that ASP.net requires. Does anybody have any experience with ASP.Net's authentication protocol?
Im gonna be checking this post throughout the day, so I can post more info if required.
Edit: Ive also tried running my script against a basic http auth server running at home, and it authenticates, so Im pretty sure the request is set up properly.
It appears that IIS is set up to do basic authentication, ASP.NET will be most probably be configured to use windows authentication.
As you have said that authentication works via browser, so the best bet for you is to use tool such as fiddler to capture request/response when connecting via browser and also when connecting via your code. Compare them to troubleshoot the issue.
For example, I remember a case where the web site first requested authentication credentials and then re-directed to different url which prompted for different credentials.

How to access bpos Exchange online via WebDav?

I am trying to access my exchange mailbox via WebDav.
Locally I used the following URL to do so:
https://server/exchange/username/inbox/
Since we moved our server to bpos (exchange online) I am not sure which URL to use to access my mailbox. The bpos server does handle multiple domains and I am not sure where to put the domain in the url above.
Does anyone has some experience in accessing the bpos exchange server programmatically?
Thanks
Andreas
After a long search and dozens of tests I seem to have found my problem:
First of all, WebDav does NOT work with Exchange Online.
There is a solution using WebServices, that works quite nice.
I seem to have to set the Exchange Version to 2007_SP1. I did not find any option to leave this item blank or have it detected.
var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
// Just to get the trace messages
service.TraceEnabled = true;
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
service.UseDefaultCredentials = false;
service.Credentials = new WebCredentials("<Username>", "<Password>");
// Autodiscover does NOT work if Exchange is not in the local net
// This is the url you have to use for german account (red002)
service.Url = new Uri("https://red002.mail.emea.microsoftonline.com/ews/Exchange.asmx");
What I still cannot understand is why you have to know the exchange version in advance, and have no option to negotiate that with a call.
Similar is the fact that I have to know the URL to be able to connect to the exchange server. Is it not the basic idea of the cloud to NOT have to know where your data is hosted?
I hope this code helps somebody. I sure would have needed this advice :-)
We use "WebDAV .NET for Exchange", commercial library to access to Microsoft Exchange Online server over the WebDAV protocol. You have to use Forms Based Authentication to login and url is like https://red003.mail.microsoftonline.com/exchange/xxxxxx#xxxxx.microsoftonline.com

Resources