Development discussions around Shopify APIs
To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more
I want to create a fullfilment in a private shopify app, but instead of the expected json I get a HTML with a oauth login link returned. (see below)
what do I need to change?
Other Api's like creating products do work
URL
POST https://{mySlug}.myshopify.com/admin/api/2021-10/orders/{orderid}/fulfillments
I also tried
POST https://{apikey}:{password}@{mySlug}.myshopify.com/admin/api/2021-10/orders/{orderid}/fulfillments
Body
{"fulfillment":{"location_id":{locationid},"notify_customer":false}}
Headers:
X-Shopify-Access-Token - {myAccessToken}
I've seen the following link
https://community.shopify.com/c/shopify-apis-and-sdks/post-returns-200-and-login-page/m-p/877771
Therefore i tried to to post with and without basic auth. Also I set "Cache-Control" to "max-age=0"
but same result.
I tried it with HTTP Client in C# and with postman directly. both same results. In the C# client I also explicitly disable cookiesC# Code creating the http client
var handler = new HttpClientHandler
{
UseCookies = false
};
var client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("X-Shopify-Access-Token",accessToken);
client.DefaultRequestHeaders.Add("Cache-Control", "max-age=0");
Code to post to the api
var req = new RequestFulfillment.ShopifyFulFillmentRequest()
{
Fulfillment = new ()
{
LocationId = locationid,
NotifyCustomer = notifyCustomer
}
};
using var client = ResolveClient();
string content = JsonSerializer.Serialize(req);
try
{
var response = await client.PostAsync(url, new StringContent(content, Encoding.UTF8, "application/json"));
var respcontent = await response.Content.ReadAsStringAsync();
var responseDto = JsonSerializer.Deserialize<CreateFulfillmentResponse>(respcontent);
Response I get
200 OK but his thml
Solved! Go to the solution
This is an accepted solution.
Hey @Sarah_Fron,
I was able to replicate and resolve a similar response by appending the expected .json
at the end of the request URL, per the formatting example(s) in our reference docs here.
ex. https://{shop}.myshopify.com/admin/api/{version}/{resource}.json
- Cheers!
awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hey @Sarah_Fron,
I was able to replicate and resolve a similar response by appending the expected .json
at the end of the request URL, per the formatting example(s) in our reference docs here.
ex. https://{shop}.myshopify.com/admin/api/{version}/{resource}.json
- Cheers!
awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks so ,much, that helped 🙂
User | RANK |
---|---|
6 | |
5 | |
5 | |
5 | |
4 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022