In my app, I have send some Request to server using POST Method and in response following JSON string printed on console :
[
{
"title": "American Heart Association",
"link": "www.americanheart.org/"
},
{
"title": "EverydayHealth.com",
"link": "www.everydayhealth.com"
},
{
"title": "GetFitSlowly.com",
"link": "www.getfitslowly.com"
}
]
so, how to parse it, and take title and link from this string
Yes as Jhaliya posted above...
Tutorial: JSON Over HTTP On The iPhone download from code here copy JSON library in your code and simple
object = [yourResponseInString JSONValue];
in object you'll get Array or dictionary..;)
Related
I send email without user authentication, automatic method.
{
"message":
{
"subject": "Envio de email Teste do MS Graph",
"body":
{
"contentType": "HTML",
"content": "Testando envio"
},
"toRecipients":
[
{
"emailAddress":
{
"address": "xxxxx#gmail.com"
}
}
],
"attachments":
[
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "Teste de Anexo",
"contentLocation": "e:\ramos.xlsx",
"isInLine":"true"
}
]
}
}
How do I attach several files to the email?
I know a parameter called attachment, but I was unable to use it to point to a physical file path. I need to point to several files.
How to transform the file into base64 using VBA? Is there an API inside Graph that does this?
Solved, the problem was that I needed to convert to base64
As of now you cannot point out the files since contentLocation is not supported according to the document. And I am not from the VBA side but you can try getting the file using this thread and you can encode the data by following this thread which concentrates on text file, you can give a try with Excel file.
You will need to convert the file to base64.
import base64
def encode_base64(attachment_path):
data = open(attachment_path, 'rb').read()
base64_encoded = base64.b64encode(data).decode('UTF-8')
return base64_encoded
Define variable
attachment = encode_base64('c:/your_folder/file.xlsx')
After that you can pass to as args to JSON
"attachments": [
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "HappyCodeAgosto.xlsx",
"contentType": "application/vnd.ms-excel",
"contentBytes": attachment
}
]
I'm following the tutorial here https://developer.bigcommerce.com/api-docs/storefront/widgets/widgets-tutorial
I made the widget template by performing a post request to https://api.bigcommerce.com/stores/81mdugvyu5/v3/content/widget-templates with this in the body
{
"name": "Header Images",
"template": "{{#each images}}<a href='{{image_url}}'><img src={{image_source}} style='width:33.3%'/></a>{{/each}}"
}
The response was successful.
I then performed a post request to https://api.bigcommerce.com/stores/81mdugvyu5/v3/content/widgets
with this in the body
{
"name": "Header Images",
"widget_configuration": {
"images": [
{
"image_url": "https://google.com",
"image_source": "https://cdn11.bigcommerce.com/s-n0i50vy/images/stencil/1280x1280/products/91/309/thekinfolktablecover_1024x1024__80715.1456436719.jpg?c=2&imbypass=on"
},
{
"image_url": "https://google.com",
"image_source": "https://cdn11.bigcommerce.com/s-n0i50vy/images/stencil/1280x1280/products/109/361/kinfolkessentialissue_1024x1024__22507.1456436715.jpg?c=2&imbypass=on"
},
{
"image_url": "https://google.com",
"image_source": "https://cdn11.bigcommerce.com/s-n0i50vy/images/stencil/500x659/products/85/282/livingwithplants_grande__26452.1456436666.jpg?c=2&imbypass=on"
}
]
},
"widget_template_uuid": "7c5f05c2-2361-45a3-bb99-89554dd145ee"
}
The response was successful.
My custom widget does then appear in page builder but when I try to add it I receive this error
This widget is not supported by Page Builder. Please consult our developer documentation for more information on how to make your
widget compatible with Page Builder
When I visit the developer documentation it links to on how to make it compatible with Page Builder I don't see any mention of Page Builder.
Is there any way to find out how to make the tutorial widget compatible with Page Builder?
#Mikhail was correct. I was able to add it as a widget accessible by page builder by specifying a schema in the body of my widget-templates post request. After sending another request with the schema added like this:
{
"name": "Header Images",
"template": "{{#each images}}<a href='{{image_url}}'><img src={{image_source}} style='width:33.3%'/></a>{{/each}}",
"schema": [
{
"type": "tab",
"label": "Content",
"sections": []
}
]
}
It worked.
You can find more information about schema settings for page builder here https://developer.bigcommerce.com/stencil-docs/page-builder/page-builder-overview
and you can find a list of the items available in your schema here https://developer.bigcommerce.com/stencil-docs/page-builder/schema-settings
I am trying to build Slack application with asp net core server. Currently, I have added Slash command which makes a request to my local server through ngrok. Once my server receives that request, it makes a post request to configured slack webhook to display interactive message which looks like pic from attachment.
I want user to be able to select yes or no and receive the result in my controller, but I can't realize how to tell Slack where should it make a post request. I attach the code of this message which is posted through weebhook into Slack:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a section block with a button."
}
},
{
"type": "actions",
"block_id": "actionblock789",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Yes"
},
"style": "primary",
"value": "yes"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "No"
},
"value": "no"
}
]
}
]
}
What I have in netcore is TestController with route /api/test which I suppose should receive from Slack a payload where information about selected button is set, but I couldn't find a way where specify a url in this json code.
You can not configure a URL in the JSON code. That is not how it works with the Slack API.
Slack will send all responses to interactive message - like when someone clicks on a button - to the configured request URL of your Slack app. Check out this link how to find that parameter: documentation
Please help me for XSLT code which will work in DataPower for following input
Input: {
"Timestamp": "2018-12-19T10:52:21.0870605-05:00",
"ResponseType": "Success",
"Name": [
{
"Code": "1001",
"Description": "ABC",
"Number": "123"
},
{
"Code": "1002",
"Description": "XYZ",
"Number": "123"
},
{
"Code": "1003",
"Description": "PQA",
"Number": "123"
},
{
"Code": "1004",
"Description": "MNO",
"Number": "123"
}
]
}
Output:
XSLT Variable
xsl:variable_code = 1001,1002,1003,1004
xsl:variable_Name : ABC,XYZ,PQA,MNO
XSLT will not work with this format natively (XSLT input is always XML, but output can be whatever).
There are ways to get around this.
1 - Use Gatewayscript transformation instead. You can find example on your own Datapower "sample" folders". The files are ending with ".js"
2 - You can still do it in XSLT, but need to auto-convert the JSON to XML using the input settings and a special, hidden, magic variable.
How-to:
In your object (XML Firewall, or Multi-Protocol Gwy), Specify the input as "JSON"
At the step in the rule where you want to use XSLT to interpret this input, do not use the vairable "PIPE" or "INPUT" as input, but "__JSONASJSONX". MORE INFO HERE.
This will allow you to navigate the JSON file after conversion to XML.
Here is an example of the conversion.
The rest is just normal XSLT programming on the Datapower... you can create a JSON or XML output... your choice !
I have been trying to create a job to load a compressed json file from Google Cloud Storage to a Google BigQuery table. I have read/write access in both Google Cloud Storage and Google BigQuery. Also, the uploaded file belongs in the same project as the BigQuery one.
The problem happens when I access to the resource behind this url https://www.googleapis.com/upload/bigquery/v2/projects/NUMERIC_ID/jobs by means of a POST request. The content of the request to the abovementioned resource can be found as follows:
{
"kind" : "bigquery#job",
"projectId" : NUMERIC_ID,
"configuration": {
"load": {
"sourceUris": ["gs://bucket_name/document.json.gz"],
"schema": {
"fields": [
{
"name": "id",
"type": "INTEGER"
},
{
"name": "date",
"type": "TIMESTAMP"
},
{
"name": "user_agent",
"type": "STRING"
},
{
"name": "queried_key",
"type": "STRING"
},
{
"name": "user_country",
"type": "STRING"
},
{
"name": "duration",
"type": "INTEGER"
},
{
"name": "target",
"type": "STRING"
}
]
},
"destinationTable": {
"datasetId": "DATASET_NAME",
"projectId": NUMERIC_ID,
"tableId": "TABLE_ID"
}
}
}
}
However, the error doesn't make any sense and can also be found below:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0: "
}
],
"code": 400,
"message": "Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0: "
}
}
I know the problem doesn't lie either in the project id or in the access token placed in the authentication header, because I have successfully created an empty table before. Also I specify the content-type header to be application/json which I don't think is the issue here, because the body content should be json encoded.
Thanks in advance
Your HTTP request is malformed -- BigQuery doesn't recognize this as a load job at all.
You need to look into the POST request, and check the body you send.
You need to ensure that all the above (which seams correct) is the body of the POST call. The above Json should be on a single line, and if you manually creating the multipart message, make sure there is an extra newline between the headers and body of each MIME type.
If you are using some sort of library, make sure the body is not expected in some other form, like resource, content, or body. I've seen libraries that use these differently.
Try out the BigQuery API explorer: https://developers.google.com/bigquery/docs/reference/v2/jobs/insert and ensure your request body matches the one made by the API.