Apple CalDav server behaves erratically when asking for expanded retrieval of recurring event - icloud

I am using CALDAV:calendar-multiget REPORT for expanded retrieval of recurring event.
The request looks like:
curl -X REPORT \
https://caldav.icloud.com:443/1234567890/calendars/work/ \
-H 'authorization: Basic XXXXXX' \
-H 'content-type: application/xml; charset=utf-8' \
-d '<c:calendar-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<c:calendar-data>
<c:expand start="20171201T000000Z" end="20180101T000000Z"/>
</c:calendar-data>
</d:prop>
<d:href>/1234567890/calendars/work/ABC-DEF-GHI-JKL.ics</d:href>
</c:calendar-multiget>'
Sometimes the Apple server gives expanded events in the response but sometimes it gives only the master event without expansion.
Am I doing anything wrong here?
Has anyone else faced this behaviour?

Related

PostgREST: Requests to volatile RPC with a single json parameter and which fires multiple triggers taking a very long time to complete - Solved

I am experiencing major performance issues when calling a stored procedure via PostgREST compared when calling it via psql. Both methods complete successfully, but the PostgREST takes ~1 min compared to 2 seconds with psql. There are many statement levels and a few row-level triggers fired as a result of this procedure.
This procedure updates the database, another update procedure has the same issues,
Calling from psql:
set role myrole;
start transaction;
WITH pgrst_source AS (WITH pgrst_args AS (SELECT NULL) SELECT "api"."docket_creation"('{"dockets":[{"docket":{},"transactions":[{"transaction":{"batch_id":null,"best_before_date":null,"docket_id":1417,"minimum_price":1.5,"note":"","price":3,"product_code":"TL12","product_cost":1,"product_description":"","product_group_id":null,"product_id":217,"product_name":"12 Tray Large","quantity":1,"vat_rate_id":4,"vat_rate_percentage":0,"return_reason_id":null,"transaction_type_id":2},"transaction_discounts":[{"discount_percentage":5,"discount_type_id":10,"discount_value_per_unit":null,"minimum_quantity":null,"note":""}],"transaction_returns":[],"transaction_commissions":[{"commission_id":null,"commission_percentage":0,"commission_type_id":2,"customer_id":1,"delivery_agent_id":0,"effective_from":null,"effective_to":null,"is_cumulative":true,"owner":2,"product_id":217}]}],"docket_buy_x_get_y_discounts":[]}]}'::json) AS pgrst_scalar)
SELECT
null::bigint AS total_result_set,
pg_catalog.count(_postgrest_t) AS page_total,
(json_agg(_postgrest_t.pgrst_scalar)->0)::character varying AS body,
coalesce(nullif(current_setting('response.headers', true), ''), '[]') AS response_headers
FROM (SELECT "pgrst_source".* FROM "pgrst_source" ) _postgrest_t;
Or simply:
SELECT "api"."docket_creation"('{"dockets":[{"docket":{},"transactions":[{"transaction":{"batch_id":null,"best_before_date":null,"docket_id":1417,"minimum_price":1.5,"note":"","price":3,"product_code":"TL12","product_cost":1,"product_description":"","product_group_id":null,"product_id":217,"product_name":"12 Tray Large","quantity":1,"vat_rate_id":4,"vat_rate_percentage":0,"return_reason_id":null,"transaction_type_id":2},"transaction_discounts":[{"discount_percentage":5,"discount_type_id":10,"discount_value_per_unit":null,"minimum_quantity":null,"note":""}],"transaction_returns":[],"transaction_commissions":[{"commission_id":null,"commission_percentage":0,"commission_type_id":2,"customer_id":1,"delivery_agent_id":0,"effective_from":null,"effective_to":null,"is_cumulative":true,"owner":2,"product_id":217}]}],"docket_buy_x_get_y_discounts":[]}]}')
This takes about 2 secs.
When calling from a webapp or via curl with the call
curl 'https://<server>/hhdb_api/rpc/docket_creation' \
-X 'POST' \
-H 'Connection: keep-alive' \
-H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"' \
-H 'Prefer: params=single-object' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'Authorization: Bearer $bearer_token' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/plain, */*' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36' \
-H 'DNT: 1' \
-H 'Origin: https://hh-tincan-dev.srv.handheld.ie' \
-H 'Sec-Fetch-Site: same-site' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Referer: https://hh-tincan-dev.srv.handheld.ie/' \
-H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
--data-raw '{"dockets":[{"docket":{},"transactions":[{"transaction":{"batch_id":null,"best_before_date":null,"docket_id":1428,"minimum_price":1.5,"note":"","price":3,"product_code":"TL12","product_cost":1,"product_description":"","product_group_id":null,"product_id":217,"product_name":"12 Tray Large","quantity":1,"vat_rate_id":4,"vat_rate_percentage":0,"return_reason_id":null,"transaction_type_id":2},"transaction_discounts":[{"discount_percentage":5,"discount_type_id":10,"discount_value_per_unit":null,"minimum_quantity":null,"note":""}],"transaction_returns":[],"transaction_commissions":[{"commission_id":null,"commission_percentage":0,"commission_type_id":2,"customer_id":1,"delivery_agent_id":0,"effective_from":null,"effective_to":null,"is_cumulative":true,"owner":2,"product_id":217}]}],"docket_buy_x_get_y_discounts":[]}]}' \
--compressed
This will take over a minute.
I would expect both of these invocations to take a similar time.
I have enabled extensive logging to try to track this down the difference between the two methods seems to be the delays when entering a nested trigger
~
I have raised this as an issue on the PostgREST's GitHub with some configuration details:
https://github.com/PostgREST/postgrest/issues/1836
This issue is now solved please refer to the PostgREST github issue for details

Receiving Invalid Grant Type Error Received From AWS Cognito When Supply Auth Code : How do I get Id and access tokens for testing?

I am unable to successfully acquire an id token/access token from my AWS cognito user pool when I supply an auth code. I have written a shell script (see below), and receive invalid_grant back from the server.
I have encoded the base64 Authorization Basic header for client_id:client_secret generated with python as:
import base64
encode='my_client_id_string:my_client_secret_string'
base64.b64encode(encode)
#!/usr/bin/env sh
curl --location --request POST 'https://<domain>.auth.us-east-2.amazoncognito.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic <base64 encode string client_id:client_secret>' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=<client_id from app settings' \
--data-urlencode 'code=<code received from redirect url to my localhost app endpoint>' \
--data-urlencode 'redirect_uri=http://localhost:8000/my_redirect'
Any ideas?
Solved it!
The problem was caused by an invalid client id. I had supplied a typo for the client id value!

CardDav (iCloud) what can be a reason for patches forbidden responses?

Does anyone else also noticed strange forbidden responses for existing vcard files updates?
See my curl example:
curl --location --request PUT 'https://p52-contacts.icloud.com/1........4/carddavhome/card/53cd4fa9-6fb0-40c3-9975-ff41909c7d9c.vcf' \
--header 'Authorization: Basic [secret]' \
--header 'Content-Type: text/vcard; charset=utf-8' \
--data-raw 'BEGIN:VCARD
VERSION:3.0
N:Last;contact-update_simple;Middle;Prefix;Suffix
FN:Prefix contact-update_simple Last Suffix
UID:53cd4fa9-6fb0-40c3-9975-ff41909c7d9c
END:VCARD'
Response most time is "403 Forbidden" - but some calls seems to pass.

Trying to get a session value from a post call in Postman: TypeError: postman.getResponseHeader is not a function

In Postman, I am trying to retrieve a session value returned from a post call and use it in another get call.
I mean, I called via Postman:
curl -X POST \
https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0 \
-H 'Accept: */*' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: skyscanner-skyscanner-flight-search-v1.p.rapidapi.com' \
-H 'Postman-Token: xxxx' \
-H 'User-Agent: PostmanRuntime/7.15.0' \
-H 'accept-encoding: gzip, deflate' \
-H 'cache-control: no-cache' \
-H 'content-length: 177' \
-d 'inboundDate=2019-11-25&cabinClass=economy&children=0&infants=0&Country=BR&Currency=BRL&locale=pt-BR&originPlace=GRU-sky&destinationPlace=MCZ-sky&outboundDate=2019-11-19&adults=2'
It returned in Header among others keys:
Location →http://partners.api.skyscanner.net/apiservices/pricing/uk2/v1.0/b5b906e9-164e-4f1d-b5ce-9085b8a3506d
Now, I want to call another API and I must use the session id returned in previous call. It is after /v1.0/. In this case it is b5b906e9-164e-4f1d-b5ce-9085b8a3506d
The first steps is getting the Location key value but I am getting the error mentioned in this question title (see picture attached for more details).
So my straight question is how can I retrieve the Location value from another post request? Well, a complementary and helpfull coment will be how to parse and get only the session id but naturally firsly I have to fix how retrieve the whole Location value.
It is more or less this what I am trying:
var sessionKey = JSON.parse(postman.getResponseHeader('Location') );//maybe here applying some regular expression to get only the value after the last "/"
pm.environment.set("sessionkey", postman.getResponseHeader("sessionkey"));
My question is somehow close to In POSTMAN how do i get substring of response header item? but here the question author is able to use postman.getResponser and it seems he didn't get a final answer at the end.
My Postman version is 7.3.4 (Latest) (I have just updated it).
*** edited after first sugestion
*** another tentative failling
var locationHeader = pm.response;
console.log(pm.response); //Print successfully all response including body and header
var jsonData = JSON.parse(pm.response); //exception: There was an error in evaluating the Pre-request Script: JSONError: Unexpected token u in JSON at position 0
console.log("Location = " + jsonData.Location);
PS. it is interesting that
pm.request.headers.add({key: 'X-RapidAPI-Host', value: 'skyscanner-skyscanner-flight-search-v1.p.rapida.com'})
works properly in my collection Pre-request scripts. It is obvious to have pm.request.headers.get, isn't it? But it doesn't have.
*** edited
I also added this question in https://community.getpostman.com/t/trying-to-get-a-session-value-from-a-post-call-in-postman-typeerror-postman-getresponseheader-is-not-a-function/6804
*** edited
Just in case someone get interested, my final implementation is
var locationHeader = pm.response.headers.get("Location").split('/');
var locationPosition = locationHeader.length-1;
var sessionKey = locationHeader[locationPosition];
pm.environment.set("sessionkey", sessionKey);
in Test tab while calling POst Create Session
Add the following script in the first request test, it will set sessionkey value that you can use for later calls.
var locationHeader = postman.getResponseHeader("Location").split('/');
var sessionKey = locationHeader[locationHeader.length-1];
pm.environment.set("sessionkey", sessionKey);

Curl Error when trying to POST to AWS endpoint

I got
error: {"error":"Unexpected token ‘"}
with the curl command below.
What gives?
curl -X POST \
-H "X-Parse-Application-Id:SomeID" \
-H "Content-Type: application/json" \
-d ‘{“number”:"3016524500"}’ \
http://somedomain.com/parse/functions/testFunction
Please suggest.
I think the issue is that you're using different characters than the actual ' and " characters. Try replacing ” with " and ‘ with '.