Browse an api from mobile running by pc's localhost - api

If my api is running on my pc, when I browse localhost:3000/purchases I get this json response.
[
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}
]
Now I want to get the same response by visiting the exact same url from mobile
[ both are under same wifi network ]
What should I do?
[ my server is golang with postgres, my client is angular, but I also want to see json response from my mobile ]

You just need to get your local ip of your PC :
win + R
write "cmd"
write "ipconfig /all"
find you local ipV4 "192.168.x.x"
Now you just have to visiting : "192.168.x.x/purchases"
If you really want to use "localhost:3000/purchases" to access it by your mobile, you need to install an adroid Web server app

Related

How to pass parameters in xmlhttp (vba)

I have a program that I would like to integrate with WooCommerce. I am running into an issue when attempting to add a new product. Specifically the category and image fields. The following code works properly: (I changed to put instead of post so I would update the same product rather than continuing to add incomplete items)
myurl = "https://url.com/wp-json/wc/v3/products?sku=" & UPC & "&name=" & title & "&regular_price=" & price &consumer_key=" & rs!woocomkey & "&consumer_secret=" & rs!woocomsecret
xmlhttp.Open "put", myurl, False
xmlhttp.setRequestHeader "accept", "application/json"
xmlhttp.send
It works but sets the category to id 174 uncategorized
when I try to add the addition parts below and mess with the formatting slightly I either get the same result or the error message Below it
myurl = "https://url.com/wp-json/wc/v3/products?sku=" & UPC & "&name=" & title & "&regular_price=" & price & "&categories=[{id=" & cat2 & "}]&images=[{src=http://url.com/pos/default.jpg}]&consumer_key=" & rs!woocomkey & "&consumer_secret=" & rs!woocomsecret
{"code":"rest_invalid_param","message":"Invalid parameter(s): categories","data": {"status":400,"params":{"categories":"categories[0] is not of type object."}}}
I believe the issue is that I don't know the proper syntax when there is a subcategory. Here is the related api document from Woocommerce. I don't know PHP, Curl or the other options they list.
curl -X POST https://example.com/wp-json/wc/v3/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Quality",
"type": "simple",
"regular_price": "21.99",
"description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpisegestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
"short_description": "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
"categories": [
{
"id": 9
},
{
"id": 14
}
],
"images": [
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"
},
{
"src": "http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg"
}
]
Any Help would be greatly appreciated!

Running "ansible-playbook playbook.yml" outputs fatal: [localhost]: FAILED

Following the ansible 2-org-network example tutorial, when running "ansible-playbook playbook.yml" command, this outputs
"TASK [ibm.blockchain_platform_manager : Authenticate to IBM Blockchain Platform service] *****************************************************
fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", "content": "{\"context\":{\"requestId\":\"3aed45737c8d4cc7a3a52b03cfbf7e64\",\"requestType\":\"incoming.Identity_Token\",\"userAgent\":\"ansible-httpget\",\"url\":\"https://iam.cloud.ibm.com\",\"instanceId\":\"iamid-5.2-7439-f51ff7a-6488f4d469-jxdn5\",\"threadId\":\"f61a\",\"host\":\"iamid-5.2-7439-f51ff7a-6488f4d469-jxdn5\",\"startTime\":\"15.02.2020 21:04:28:625 GMT\",\"endTime\":\"01.01.1970 00:00:00:000 GMT\",\"elapsedTime\":\"0\",\"locale\":\"en_US\",\"clusterName\":\"iam-id-prams03-igyr\"},\"errorCode\":\"BXNIM0415E\",\"errorMessage\":\"Provided API key could not be found\"}", "content_language": "en-US", "content_length": "517", "content_type": "application/json", "date": "Sat, 15 Feb 2020 21:04:28 GMT", "elapsed": 0, "json": {"context": {"clusterName": "iam-id-prams03-igyr", "elapsedTime": "0", "endTime": "01.01.1970 00:00:00:000 GMT", "host": "iamid-5.2-7439-f51ff7a-6488f4d469-jxdn5", "instanceId": "iamid-5.2-7439-f51ff7a-6488f4d469-jxdn5", "locale": "en_US", "requestId": "3aed45737c8d4cc7a3a52b03cfbf7e64", "requestType": "incoming.Identity_Token", "startTime": "15.02.2020 21:04:28:625 GMT", "threadId": "f61a", "url": "https://iam.cloud.ibm.com", "userAgent": "ansible-httpget"}, "errorCode": "BXNIM0415E", "errorMessage": "Provided API key could not be found"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "set_cookie": "sessioncookie=76599c5849373452d151007c6314be2a; Path=/; Secure; HttpOnly", "status": 400, "transaction_id": "3aed45737c8d4cc7a3a52b03cfbf7e64", "url": "https://iam.cloud.ibm.com/identity/token", "x_powered_by": "Servlet/3.1"}
PLAY RECAP ***********************************************************************************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
"
I don't know if this an error, but a node file should be created but it's not. a screenshot of the output is attached
Edit: I'm using ibm blockchain platform vscode extension. changed the infrastructure.type from "saas" to "software" while the previous error is gone another one apperead "I'm using the ibm platform extension on vs code. changed the infrastructre.type from "saas" to "software" in the "playbook.yaml" file, that error is gone but a new appeared
"fatal: [localhost]: FAILED! => {"changed": false, "content": "", "elapsed": 0, "msg": "Status code was -1 and not [200]: Request failed: ", "redirected": false, "status": -1, "url": "https://ibp-console.example.org:32000/ak/api/v1/components?skip_cache=yes"}
PLAY RECAP ***********************************************************************************************************************************
localhost : ok=11 changed=3 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
"
The ansible role provides support for 3 options, saas, software and docker.
saas refers to IBM Blockchain platform in the cloud, ie the software as a service offering in IBM Cloud, so you need to have provisioned IBM Blockchain platform on the IBM Cloud for this option.
software refers to IBM Blockchain platform software which you need to purchase from IBM and have it deployed.
docker refers to a local deployment on your machine using docker of the Open Source Hyperledger images it creates a local fabric network on your machine.
I'm guessing that you would want to use the docker option.

When I use filterBy my Vue.js application stops working

When I am using filterBy my application stop working, and nothing shows up in the page the VM instance div is missing form the DOM. What might be the reason?
<div v-else v-for="events in profDetails.events | filterBy events.type">
Below is the JSON Format :
{
"usrId": "1",
"events": [{
"sdate": "02/13/2017",
"author": "suthota1#email.com",
"imgsmall": "images/backgroundhead.svg",
"usrId": 1,
"title": "BigFix Detect (Endpoint Detection & Response) Marketing Announce",
"type": "announcements",
"edate": "02/13/2017",
"tags": "",
"bu": ["Security"],
"scope": "CISOs, SOC Analysts",
"contact": "",
"createTS": "June 01, 2017 # 04:53 PM",
"id": 1,
"region": "North America",
"imglarge": "images/backgroundhead.svg",
"kma": "New landing page, demo video, webinar, comprehensive digital campaign, try/buy offer, immersive demos at RSA, analyst quick take report",
"status": "Published",
"desc": "IBM launches new rapid threat detection and remediation platform. The top tactic employed by attackers is to avoid being detected in the first place. This has spawned a flood of endpoint detection and response (EDR) tools that have primarily focused on detection of endpoint threats. Unlike other vendors, BigFix sees, understands and acts on all threats on the endpoint through a single platform, detecting malicious behavior and delivering targeted remediation on impacted endpoints enterprise wide in minutes."
}, {
"sdate": "07/26/2017",
"author": "suthota1#email.com",
"imgsmall": "images/backgroundhead.svg",
"usrId": 1,
"title": "IBM X-Force Red Portal 2.0",
"type": "announcements",
"edate": "07/26/2017",
"tags": "",
"bu": ["Security"],
"scope": "Technical security testing",
"contact": "",
"createTS": "June 01, 2017 # 04:53 PM",
"id": 2,
"region": "North America",
"imglarge": "images/backgroundhead.svg",
"kma": "Announce as Tier 1 story at Blackhat for Security",
"status": "Published",
"desc": "TECHIBM X-Force Red, is a new global force of the industry's."
}],
"status": "SUCCESS"
}

Is there a web-based API available to find User's TimeZone based on his/her Tel countrycode?

I do require an API (preferably RESTful), to find the timezone of a dialed number (e.g. +44xxxvvvyyyy (UK) = GMT etc) for an academic project. I thought there might be an API available somewhere that stops me to write the service and make it available myself !! I am well aware of the issues the service should address with regards to multi-zoned countries like US and Russia.
Any help would be appreciated in advance.
Googling 'telephone country code web service' came back with:
https://restcountries.eu
In particular, what you were looking for:
https://restcountries.eu/rest/v1/callingcode/
Australia:
https://restcountries.eu/rest/v1/callingcode/61
[
{
"name": "Australia",
"capital": "Canberra",
"altSpellings": [
"AU"
],
"relevance": "1.5",
"region": "Oceania",
"subregion": "Australia and New Zealand",
"translations": {
"de": "Australien",
"es": "Australia",
"fr": "Australie",
"ja": "オーストラリア",
"it": "Australia"
},
"population": 23868800,
"latlng": [
-27,
133
],
"demonym": "Australian",
"area": 7692024,
"gini": 30.5,
"timezones": [
"UTC+05:00",
"UTC+06:30",
"UTC+07:00",
"UTC+08:00",
"UTC+09:30",
"UTC+10:00",
"UTC+10:30",
"UTC+11:30"
]
...

format json in rails3

I'm trying to access a JSON version of my variable. I tried using . notation on the shows variable as I presumed it was now formatted as a json object. #shows.title but that caused an error.
I tried to use #shows.to_json.title for it to work but still no good. I thought when you format.json it already calls the to_json and that was the idea of using format or am in incorrect in thinking this way. If so what does format do then.
class ShowsController < ApplicationController
# GET /shows
# GET /shows.json
def index
#shows = Show.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: #shows }
end
end
index.html.erb
<p> #shows.title <p>
the structure I'm looking for in JSON would be like this.
[
{
"id": "feature",
"width":570,
"title": "Lorem ipsum dolor amet emipsum do omnis iste natus",
"description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantiu mdoloremque laudantium.",
"img": "img/work/img1.jpg",
"url": "http://www.bla.com"
},
{
"id": "show",
"width":200,
"title": "Lorem ipsum dolo",
"description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantiu mdoloremque laudantium.",
"img": "img/work/img2.jpg",
"url": "http://www.bla.com"
}
]
UPDATED: maybe I'm not explaining this correctly.
My goal here is to have my action in the controller call the index.html page, which it does now. On that page is a jquery plugin that requests a JSON object with all the data from the database. This way it can parse through the JSON and render all the objects on the index.html page using jquery plugin. The reason for this is it's using a plugin called jquery.masonry.js & jquery.infinitescroll.js which is now setup to use multiple JSON structures to create my pages.
If you need your collection to be accessible to jquery, then you can render it as a json string inside of a script block. So for example in your index.html.erb you could put:
<%= javascript_tag "var shows = #{#shows.to_json}" %>
Which will render
<script type="type/javascript"> var shows = { "your":"json", "object":"YAY" } </script>
But you still want to respond_to html