I am facing a problem - can not update the price of the variant using the ShopifyAPI..
while updating the price of the variant, it is giving the error
#remote_errors=#<\ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = Unprocessable Entity.>, #validation_context=nil, #errors=#<\ActiveResource::Errors:0x000000029eb1d0 ...>>, #messages={:base=>["Options are not unique"]}
'\' after '<' is required to show the error, otherwise stack overflow is hiding the error.
as required on another question
on production store, the request id is "38f5c3b3b7bdf4433724a845c6df4571"
on test store, the request id is "6050f165586b631e81b840dc0e1e6807"
More Findings
variant price change on test store
p = ShopifyAPI::Product.last
v = p.variants.first
v.price = "8.00"
v.save
initial price of variant = "9.00"
returns false, with error #messages={:base=>["Options are not unique"]}
request id 978ad18483f40ff3946df18df0a9d1d8
.
.
variant price change on live store
p = ShopifyAPI::Product.first
p.variants[0].price = "24.65"
p.save
initial price of variant = "25.65"
return true, but price is not changed
request id a9a798b631e3dd10fc81b723f2883af1
.
.
variant price change through product on test store
p = ShopifyAPI::Product.first
p.variants[0].price = "8.00"
p.save
initial price of variant = "7.00"
return true and price is updated
request id 7d995f6f6ed3bf515e69a1640f27f44a
.
.
variant price change through product on live store
p = ShopifyAPI::Product.last
v = p.variants.first
v.price = "4.00"
v.save
initial price of variant = "3.00"
returns false, with error #messages={:base=>["Options are not unique"]}
request id c6aaa5b65576eb4ec0d89715d25b787e
#messages={:base=>["Options are not unique"]}
That's your problem. Looking at the logs you're using POST to submit the request, which is used for creating new objects. Shopify is recognizing that there's already a variant with the specified options and refusing to create a new one.
If you use PUT as your HTTP method instead, Shopify will correctly interpret this as an update and everything should be fine.
This is a bug in ActiveResource 3.1+.
I have opened an ActiveResource pull request, but I am still awaiting a response at the moment.
I have committed a workaround for this bug in shopify_api v3.0.1, so upgrading this gem will fix this issue for you issue.
Related
Below is my Robot Framework code for the POST API:
Create Session Update_inventory_details
${Base_URL}
${body}= Create Dictionary distributionPointId=7 menuItemId=1 quantity=1 transactionDoneBy=11 transactionType=1 reasonId=11 barcode=null
${Headers}= Create Dictionary Content-Type=application/json Authorization=bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6InByaXRpc3dhaW4iLCJpYXQiOjE1Njc1MTQ2NDd9.o3qTPbj2KH6AgHpIf1BLV5nOlGL-fR83wSGAYyuWsBQ
${Response}= Post Request Update_inventory_details reportmenuiteminventorychange data=${body} headers=${Headers}
Log Many ${Response.status_code}
Log Many ${Response.content}
${actual_response}= Convert To String ${Response.status_code}
Should Be Equal ${actual_response} 200
On hitting the request via Robot Framework, the quantity tag value is getting appended to the actual quantity.
Example: inventory for item = 1000, adding quantity 1 via API-
Expected inventory = 1001;
Actual inventory = 10001
How do I send value in the quantity tag so that it added and not appended?
POSTMAN Request:
{
"distributionPointId":7,
"menuItemId":1,
"quantity":1,
"transactionDoneBy":11,
"transactionType":1,
"reasonId":11,
"barcode":""
}
I'm trying to update a Quote status code in MS CRM 2013 via the SDK. The issue is that I only need to update the status code and not the state code in the quote. The current State of the quote is Active and the current Status value is 10 (which I need to update to 11). I've tried a few things unsuccessfully so far:
Using the Microsoft.Crm.Sdk.Messages.SetStateRequest(), setting only the Status property:
var request = new SetStateRequest
{
EntityMoniker = new EntityReference("quote", quoteId),
Status = new OptionSetValue(11)
};
var resp = (SetStateResponse) orgService.Execute(request);
// throws Exception Microsoft.Xrm.Sdk.OrganizationServiceFault:
// "Required field 'State' is missing"
Using the Microsoft.Crm.Sdk.Messages.SetStateRequest(), setting both Status and the State property (setting the new State to the same current value):
var request = new SetStateRequest
{
EntityMoniker = new EntityReference("quote", quoteId),
State = new OptionSetValue((int) QuoteState.Active),
Status = new OptionSetValue(11)
};
var resp = (SetStateResponse) orgService.Execute(request);
// throws Exception Microsoft.Xrm.Sdk.OrganizationServiceFault:
// "The quote cannot be activated because it is not in draft state."
Calling the Update method (passing in a quote instance) in the Microsoft.Xrm.Sdk.Client.OrganizationServiceContext class. I don't have the exact code I used when I tried this, but the error I was getting was:
"The object cannot be updated because it is read-only."
I made sure the connection was made using admin user credentials, but it didn't make a difference. I also found a few other posts like this one: read-only entity error but that didn't help either.
Question
Is there a way to programmatically update the Quote status code without altering the state code? If so, how?
The Status Reason (statuscode field) of a entity depends on the Status (statecode field) value.
For example the standard values for a Quote are the following
so inside your SetStateRequest you need to set the a valid combination (for example you can't set a quote to be Active and Revised) specifying both the values.
In your question you wrote that you are using custom Status Reason, you need to check under which Status you added them and try again.
Seems like my issue has to do with the current state of the quote - Active. Apparently, Active quotes cannot be updated for the most part - I wasn't able to update its status reason even through the GUI. I found this post with a similar scenario.
As the post suggests, I was able to programmatically update my quote status by first sending it back to Draft/In Progress, and then updating its state/status to Active/11.
I'm using the Yodlee REST API and trying to call getUserTransactions.
In the request documentation, it says that only three params are required and the rest aren't. However, it seems not to work without the extra two params.
When sending with only the following:
cobSessionToken
userSessionToken
searchFetchRequest.searchIdentifier.identifier
I get the following error:
{
errorOccurred: "true"
exceptionType: "com.yodlee.core.IllegalArgumentValueException"
referenceCode: "_ad0299a4-7445-46ae-bf29-9596974af4b6"
message: "Invalid argument value: Search Result Range of TransactionSearchFetchRequest cannot be NULL"
}
It works when adding the following params
searchFetchRequest.searchResultRange.startNumber
searchFetchRequest.searchResultRange.endNumber
You need to pass on those parameters also. As those parameters will be used to paginate the transactions if those are very high in numbers.
For e.g. if the response is having
Number of hits = 1300 (From executeUserSearchRequest API)
then call getUserTransactions in loop with
1st call
StartNumber = 1
EndNumber = 500
2nd call
StartNumber = 501
EndNumber = 1000
3rd call
StartNumber = 1001
EndNumber = 1300
Meanwhile we'll get that corrected over the portal that those fields are mandatory.
I'm trying to use the .net Paymill Wrapper
When trying to add a subscription, I'm getting back a 400 Bad Request.
To illustrate the problem, I created a branch and changed the Sandbox console app to call the method to test addSubscription
The problem is happening here where the request is actually posted.
The content posted is: (as an example)
client=client_bbe895116de80b6141fd&
offer=offer_32008ddd39954e71ed48&
payment=pay_81ec02206e9b9c587513
It appears this hasn't been updated for sometime, and the original author is unresponsive via email or twitter, so I've forked the repo and am trying to fix the error.
I had a look at your code and found out that you are not creating the offer object correctly.
In your addSubscription method (SandboxConsole project), i found this code snippet
Subscription subscription = new Subscription();
subscription.Client = new Client() { Id = "client_bbe895116de80b6141fd" };
subscription.Offer = new Offer() { Id = "offer_32008ddd39954e71ed48" };
subscription.Payment = new Payment() { Id = "pay_81ec02206e9b9c587513" };
Offer object should be initialized with parameters like amount, currency, interval.
Since the offer object doesn't exist, assigning a subscription to it fails, giving you bad request error.
After a long task (14s and can be more with more than 600 call to Facebook) my app returns a 500 internal server error with the following description:
Koala::Facebook::APIError (GraphMethodException: Unsupported get request.)
What I do is something like this:
#FBGraph = Koala::Facebook::API.new
tud = MyUsers.all
tud.each do |user|
graph = #FBGraph.get_object(user.fb_user_id)
picture = #FBGraph.get_picture(user.fb_user_id)
thisTud = MyUsers.find(user.id)
thisTud.name = graph["name"]
thisTud.url = graph["link"]
thisTud.url_pic = picture
if thisTud.save
puts "Saved!"
else
puts "Error"
end
end
I receive (on the terminal) all the "Saved!", but after retrieving the data, it does automatically the mysql operations and it fails. And the data is not saved on the DB.
As suggested in this post I have placed the #FBGraph = Koala::Facebook::API.new in a new Thread, but nothing changes.
Note: when I'd do the same operations with less users, all was working good.
How hellvinz says is a facebook bug.
I have find a workaround for now that seems that works:
change this
graph = #FBGraph.get_object(user.fb_user_id)
to this
graph = #FBGraph.get_object("#{user.fb_user_id}?fields=id,name,username,picture,link")
Explicitly declaring the fields seems that solve the problem.
And if this is not sufficient there are 2 more tricks that can resolve the problem:
Calling again after a time delay (for example after an hour), and calling only the requests incomplete
Creating multiple fb app ID and accounts differentiating the requests with the accounts