Encoding issue with ageRange URL in linked in - linkedin-api

I am fetching the audiene count
https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3Acountry%3Aal))))),exclude:(and:List((or:(urn%3Ali%3AadTargetingFacet%3AageRange:List(urn%3Ali%3AageRange%3A(18%2C24)))),(or:(urn%3Ali%3AadTargetingFacet%3Adegrees:List(urn%3Ali%3Adegree%3A2049))))))
As per ref: https://learn.microsoft.com/en-us/linkedin/shared/references/v2/ads/targeting-criteria-facet-urns
The Values for Age Range allowed are : urn:li:ageRange:(18,24) urn:li:ageRange:(25,34) urn:li:ageRange:(35,54) urn:li:ageRange:(55, 2147483647)
I am getting a 400 error
{
"serviceErrorCode": 0,
"message": "Invalid query parameters passed to request",
"status": 400
}
Could you help me whether the encoding for date range in the query is correct or wrong?

In the documentation to, it states:
You're attempting to use age range in an exclude, and it can only be used in the include portion of targeting.

Related

Should I return a 404 error on a resource resulting in empty set?

If I have a resource with the following endpoint that lists all items within that resource:
/api/v1/resources
This results in:
[
{
"id": 1,
"value": -100
},
{
"id": 2,
"value": -999
}
]
It has various filters, for example:
/api/v1/resources?values_gte=999
If the filters exclude every resource and results in an empty set:
[]
Should I return a 404 status code, or a 200 status code?
Should I return a 404 status code, or a 200 status code?
200
You asked for the current representation of the resource identified by "/api/v1/resources?values_gte=999" so here it is: an empty JSON array
Notice that this is exactly what you would do if somebody requested /foo.json, and that file on your disk happened to contain exactly the contents []
HTTP status codes are metadata identifying the semantics of the response; they are used to distinguish representations of documents (2xx Successful) from representations of errors (4xx Client Error).
The payload of a 404 response would be "a representation containing an explanation of the error situation, and whether it is a temporary or permanent condition.", not an empty document.

Problem when the entity value attribute contain special character

I have tied to insert in OCB an entity with a password attribute codified:
{
"id": "prueba-tipo-string2",
"type": "StringParser",
"dateObserved": {
"type": "DateTime",
"value": "2020-08-13T08:56:56.00Z"
},
"password": {
"type": "text",
"value": "U2FsdGVkX10bFP8Rj7xLAQDFwMBphXpK/+leH3mlpQ="
}
}
OCB always response to me with the following error:
"found a forbidden character in the value of an attribute"
In Postman
{
"error": "BadRequest",
"description": "Invalid characters in attribute value"
}
Orion restricts the usage of some characters due to security reasons (script injections attack in some circumstances), see this piece of documentation. In particular, the = you have in the password attribute value.
You can avoid this, for instance, by encoding the password in base 64, or using URL encoding before storing it in Orion.
Another alternative using TextUnrestricted in attribute type. This special attribute type does not check if the attribute value contains a forbidden character. However, it could have security implications, use it at your own risk!

meetup api DATE error

I got a problem with the v3 of api meetup.com
Trying to request the api:
GET https://api.meetup.com/find/upcoming_events?sign=true&key=VALID-API-KEY&lon=32.97&page=1000&lat=4.95&page=20&offset=0&end_date_range=2018-07-19424:00:00
Expected behavior:
HTTP/1.1 400 error
{
"errors": [
{
"code": "end_time_range_error",
"message": "end_time_range is not a valid time",
"field": "end_time_range"
}
]
}
Actual behavior:
HTTP/1.1 200 success
{
[...]
}
From the docs:
end_date_range: Return events that start before this date. The date
must follow this format: YYYY-MM-DDTHH:MM:SS.
https://www.meetup.com/de-DE/meetup_api/docs/find/upcoming_events/?uri=%2Fmeetup_api%2Fdocs%2Ffind%2Fupcoming_events%2F
So it is all about:
from the docs: YYYY-MM-DDTHH:MM:SS
from my request: 2018-07-19424:00:00
Any hints?
Hopefully, it's not too late for an answer to this question. If so, maybe this would be helpful for somebody else.
The correct format for this one is 2018-07-19T16:00:00

Passing discount code in Orders API on Shopify

I have been trying to develop an app that takes an order on Shopify on a different channel. I successfully placed an order through the API but I am not able to include the discount code along with the order. The JSON object for the POST data is as below:
{
order: {
email : request.params.order.email, // string
financial_status : 'pending', // string
send_receipt : true, // boolean
send_fulfillment_receipt : false, // boolean
note : request.params.order.note, // string
discount_codes : [], // supposed to be an array of Object| Problem here,
line_items : request.params.order.line_items, // array
customer : request.params.customer, // JSON object
billing_address : request.params.order.billing_address, // JSON object
shipping_address : request.params.order.shipping_address // JSON object
}
}
According to the documentation, the discount_codes is like this -
Applicable discount codes that can be applied to the order. If no codes exist the value will default to blank. A Discount code will include the following fields:
amount: The amount of the discount.
code: The discount code.
type: The type of discount. Can be one of : "percentage", "shipping", "fixed_amount" (default).
What am I doing wrong? My discount_codes is this
[{amount: 100,code:'WELCOME10',type:'percentage'}]
Has anyone done this before?
According to this response from Shopify what you are trying to do is only possible if you pass the total_discounts field along as well with the total amount of the discount you want to apply.
As you will see in this other answer, any codes you have created through Shopify are not available to use with the API and their usage will not be recorded.
I was trying to use this API in order to test the application of different coupon codes that I was generating, but this does not seem to be possible. Apparently, the API was intended for applying discounts that are custom, not ones that already exist in Shopify. This is a frustrating limitation to me.
I successfully create orders with discounts all the time, without ShopifyPlus as that is irrelevant. The data structure that works for me looks like this:
[ { "code": "Shop By PizzleFuzzle 10%", amount: "10", "type": "percentage" } ]
The discount object is available only for Shopify Plus merchants.
Once you are a Shopify Plus merchant, you will be able to create discount codes like that:
POST /admin/discounts.json
{
"discount": {
"discount_type": "percentage",
"value": "15.0",
"code": "balderdash"
}
}
Please see more detailed documentation in the discount object at Shopify API: https://help.shopify.com/api/reference/discount
You should use the value property name instead of amount property name.
e.g.
{value: 100,code:'WELCOME10',type:'percentage'}
and not
{amount: 100,code:'WELCOME10',type:'percentage'}

Is FQL giving wrong typage?

I am starting with FQL, and I am having some issues with columns' type being not as expected.
For example, docs of table friend says that uid2 is an int, but I receive strings when I lookup this table:
SELECT uid2 FROM friend WHERE uid1 = me()
that gives me:
{
"data": [
{
"uid2": "100004469923697"
}
]
}
and with photo table too, when I expect a string at owner:
SELECT owner FROM photo WHERE owner=me()
...I receive an int:
{
"data": [
{
"owner": 100004536330032
}
]
}
Is that right?
Edit: Not parsed data, raw, as received from source and explorer
It appears that json is loosely typed, and depending on the parser used to generate the json objects numbers can be arbitrarily typed as strings or integers.
According to this Wikipedia entry, "One disadvantage is that the number 25 is reflected as a number, but may have been a string as base type in a database." No reference is given, and a quick Google didn't shed any light on this.
You'll just have to be aware that when getting json data from Facebook, the type received may not always be the type expected.