Ghost Posts API & Newsletters - ghost-blog

Running Ghost 5.2.2 and using the Admin API to publish posts.
Alongside publishing the post via the API, I want it to send it out to a specified newsletter.
As far as I can tell from the Ghost documentation (https://ghost.org/docs/admin-api/#publishing-and-scheduling-posts) all I need to do is add ?newsletter={{newsletter-slug}} to the query string when I create the post. However it schedules the post, but doesn't schedule/send the email.
Everything appears to be working well (in terms of scheduling and publishing posts), just not sending out the emails.
What am I missing?
Sample HTTPS request:
URL: {{website-url}}/ghost/api/admin/posts/?newsletter=default-newsletter&source=html
Method: POST
Body: {"posts": [{"title": "Title","status": "scheduled","html": "Content","published_at": "2022-06-15T20:07:00.000Z"}]}
Headers:
Content-Type: application/json
Authorization: Ghost {{token}}

You need setup mail service it's required in production.
Check out the documentation here https://ghost.org/docs/config/#mail

Related

Request blocked by CORs When Code is in Iframe

It's a little difficult for me to search for a response to my question because so many people are asking a different question that uses most of the same words.
I'm creating a site on Wix and using their Backend Code platform to create an HTTP endpoint. The HTTP endpoint sends an email to me using nodemailer, a feature which is not available in the browser.
While testing I set the Endpoint to be wide open using these headers.
{
"Accept": 'application/json',
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
"Access-Control-Max-Age": "86400",
"Access-Control-Allow-Headers": "Content-Type"
}
And when I send the fetch request to the HTTP Endpoint on localhost, everything works as expected.
Now, Wix requires custom HTML code to be embedded in an iframe. Developers don't have direct access to the code on their site. When I embed the code with the fetch request into an iframe and click the button to send the fetch request I get blocked by CORs.
I can see, in the Chrome Developer Console that Chrome is sending the fetch request, but along with the first Options request Chrome isn't getting the correct headers from the Endpoint. The request is subsequently blocked.
Is there any reason why being embedded in an iframe would cause this code not to work?
If this is impossible, which I fear, what other way is there to send an email from an iframe?

Use postman to send data to a apigee proxy

I want to post the following json data to apigee proxy.I created a apigee proxy with no target servers.
I copy the url from overview section in apigee and copied it into url in postman.I changed the verb in postman to Post.
I used the following apigee community post.
https://community.apigee.com/questions/54530/creating-an-api-proxy-for-
post-request.html
The data I post is { "age":30 }
When i click on the url it gives me response 200 .But in trace we can see the post action. I change postman header into Json(application/json)
But how do I check the data in my proxy?Next time I click on the url in overview section in apigee it shows me no data.
Try clicking on the individual steps in the Trace tool. There you can see the request payload that you're seeking.

Web Api - httppost - The requested resource does not support http method Get after publish on production server

when i add profile of supplier on localhost working fine. and API POSt method is working fine.
but after publish of project on server getting 400 error when i add profile of supplier.
and in response getting this.
The requested resource does not support http method 'GET'.
with 400 status
i have attached images of errors.
Project url is :
https://localefood.maqssoft.com
test-user : supplier#gmail.com
password: a#123456A
This link has the same issue that i am looking for but not give the solution of problem.
https://forums.asp.net/t/2129791.aspx
enter image description here
Make a POST request with POSTMAN.
List item Use the same URL as you did for the GET request steps above, but now choose POST to be the selected HTTP method.
Click the Body tab just under the URL, then choose the raw radio
button and JSON (application/json) from the type dropdown menu:
You may note that a new Header gets automatically added to the
request. Requests that send data need a header telling the API what
kind of data is being sent. Click the Headers tab to see the
Content-Type: application/json header:
Click Send.
If you have recently submitted a request you may not be asked to
authenticate again. If you get an Unauthorized error, request a new
access token and click Send again.

Bit.ly bitlink creation always return forbidden even after email verification?

I have registered and done email verification. Then, I try the most baisc API trying to shorten a testing link. The following is my HTTP packet.
POST /v4/shorten HTTP/1.1
Host: api-ssl.bitly.com
Content-Type: application/json
Authorization: Bearer my-generic-access-token
Cache-Control: no-cache
{
"group_guid": "shorten_link_testing",
"domain": "mytesting.site.com",
"long_url": "http://mytesting.site.com/"
}
And the following is the return from bit.ly:
{
"message": "FORBIDDEN",
"resource": "bitlinks",
"description": "You are currently forbidden to access this resource."
}
I am using Postman to test, so I am quite sure it is not the problem of my code. And the message format meets that in the documentation of bit.ly, so at least the connection is success. As far as I know, bit.ly should have 10,000 quota for free shorten link per month for every account, right? What have I missed so that I am banned from the shorten link service?
The group_guid param needs to reference the id of a group associated with your bitly account. Hit this api endpoint with your generic access token to get a list of the groups/guids bitly has associated with your account:
GET https://api-ssl.bitly.com/v4/groups.
Apparently the domain param is optional, because your account may have a default domain associated with it. It worked for me after removing the domain param altogether.
https://groups.google.com/forum/#!topic/bitly-api/9RywN3ETLkg
Hope this helps!!
I have been looking around for these issues. Currently, my solution is by removing body group_guid and getting a response 201 (created). I hope my information helps.

Wordpress json api error while generate_auth_cookie

I'm having problem with wordpress json Api When login the user. Currently I'm Using Wordpress version 4.5.1 with listed below plugin:
Here are the step I follow:
1) Generate nonce
http://example.org/api/get_nonce/?controller=user&method=generate_auth_cookie
Below is Response:
{"status":"ok","controller":"user","method":"generate_auth_cookie","nonce":"4d080ff7b8"}
2) Generate Auth Cookie
http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example
Below is Response:
{"status":"error","error":"SSL is not enabled. Either use _https_ or provide 'insecure' var as insecure=cool to confirm you want to use http protocol."}
Why I'm Getting this error?
It seems that JSON API User and JSON API Auth plugins allow by default only connections over https.
In order to turn off this setting, you should send an extra parameter in the request:
insecure=cool
So try the following request:
http://example.org/api/user/generate_auth_cookie/?nonce=+4d080ff7b8&username=example&password=example&insecure=cool

Resources