[Software]RestApiテストツールその3

Restlet Client – REST API Testing

1.Google拡張機能で、以下をインストール

Restlet Client – REST API Testing

2.例

<Request>

GET

https://map.yahooapis.jp/weather/V1/place?appid={アプリケーションID}&coordinates={緯度、経度}

<Response>

HTTP/1.1 200
status: 200
date: Wed, 11 Sep 2019 07:52:52 GMT
x-frame-options: SAMEORIGIN
cache-control: public, max-age=113
expires: Wed, 11 Sep 2019 07:54:45 GMT
vary: Accept-Encoding
content-encoding: gzip
content-length: 564
content-type: application/xml; charset=UTF-8
age: 0
via: http/1.1 edge2469.img.djm.yahoo.co.jp (ApacheTrafficServer [c sSf ])
server: ATS

<?xml version="1.0" encoding="UTF-8"?>
<YDF xmlns="http://olp.yahooapis.jp/ydf/1.0" firstResultPosition="1" totalResultsAvailable="1" totalResultsReturned="1">
	<ResultInfo>
		<Count>1</Count>
		<Total>1</Total>
		<Start>1</Start>
		<Status>200</Status>
		<Latency>0.004252</Latency>
		<Description></Description>
		<Copyright>(C) Yahoo Japan Corporation.</Copyright>
	</ResultInfo>
	<Feature>
		<Id>201909111640_35.663613_139.73229</Id>
		<Name>地点(35.663613,139.73229)の2019年09月11日 16時40分から60分間の天気情報</Name>
		<Geometry>
			<Type>point</Type>
			<Coordinates>35.663613,139.73229</Coordinates>
		</Geometry>
		<Property>
					<WeatherAreaCode />
			<WeatherList>
				<Weather>
					<Type>observation</Type>
					<Date>201909111640</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111650</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111700</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111710</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111720</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111730</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111740</Date>
					<Rainfall />
				</Weather>
			</WeatherList>
		</Property>
	</Feature>
</YDF>

[Software]RestApiテストツールその2

Insomnia

1.Download

https://insomnia.rest/download/

2.使い方

<Request>

Bodyに以下を登録

https://map.yahooapis.jp/weather/V1/place?appid={アプリケーションID}&coordinates={緯度、経度}

<Response>

<?xml version="1.0" encoding="UTF-8"?>
<YDF
  xmlns="http://olp.yahooapis.jp/ydf/1.0" firstResultPosition="1" totalResultsAvailable="1" totalResultsReturned="1">
  <ResultInfo>
    <Count>1</Count>
    <Total>1</Total>
    <Start>1</Start>
    <Status>200</Status>
    <Latency>0.003047</Latency>
    <Description></Description>
    <Copyright>(C) Yahoo Japan Corporation.</Copyright>
  </ResultInfo>
  <Feature>
    <Id>201909111625_35.663613_139.73229</Id>
    <Name>地点(35.663613,139.73229)の2019年09月11日 16時25分から60分間の天気情報</Name>
    <Geometry>
      <Type>point</Type>
      <Coordinates>35.663613,139.73229</Coordinates>
    </Geometry>
    <Property>
      <WeatherAreaCode />
      <WeatherList>
        <Weather>
          <Type>observation</Type>
          <Date>201909111625</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111635</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111645</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111655</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111705</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111715</Date>
          <Rainfall />
        </Weather>
        <Weather>
          <Type>forecast</Type>
          <Date>201909111725</Date>
          <Rainfall />
        </Weather>
      </WeatherList>
    </Property>
  </Feature>
</YDF>

[Software]RestApiテストツール

Postman

1.Download

https://www.getpostman.com/downloads/

2.Get

<Request>

URL

https://map.yahooapis.jp/geocode/V1/geoCoder

Parameter

appid

appidstringアプリケーションID
coordinatesstring緯度経度

https://map.yahooapis.jp/weather/V1/place?appid={appid}&coordinates={coordinates}

<Response>

<?xml version="1.0" encoding="UTF-8"?>
<YDF xmlns="http://olp.yahooapis.jp/ydf/1.0" firstResultPosition="1" totalResultsAvailable="1" totalResultsReturned="1">
	<ResultInfo>
		<Count>1</Count>
		<Total>1</Total>
		<Start>1</Start>
		<Status>200</Status>
		<Latency>0.006577</Latency>
		<Description></Description>
		<Copyright>(C) Yahoo Japan Corporation.</Copyright>
	</ResultInfo>
	<Feature>
		<Id>201909111545_35.663613_139.73229</Id>
		<Name>地点(35.663613,
139.73229)の2019年09月11日 15時45分から60分間の天気情報</Name>
		<Geometry>
			<Type>point</Type>
			<Coordinates>35.663613,
139.73229</Coordinates>
		</Geometry>
		<Property>
					<WeatherAreaCode />
			<WeatherList>
				<Weather>
					<Type>observation</Type>
					<Date>201909111545</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111555</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111605</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111615</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111625</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111635</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111645</Date>
					<Rainfall />
				</Weather>
			</WeatherList>
		</Property>
	</Feature>
</YDF>

[Software]XMLからJSONへ変更

http://tm-webtools.com/Tools/XmlJson

XML

<?xml version="1.0" encoding="UTF-8"?>
<YDF xmlns="http://olp.yahooapis.jp/ydf/1.0" firstResultPosition="1" totalResultsAvailable="1" totalResultsReturned="1">
	<ResultInfo>
		<Count>1</Count>
		<Total>1</Total>
		<Start>1</Start>
		<Status>200</Status>
		<Latency>0.006577</Latency>
		<Description></Description>
		<Copyright>(C) Yahoo Japan Corporation.</Copyright>
	</ResultInfo>
	<Feature>
		<Id>201909111545_35.663613_139.73229</Id>
		<Name>地点(35.663613,
139.73229)の2019年09月11日 15時45分から60分間の天気情報</Name>
		<Geometry>
			<Type>point</Type>
			<Coordinates>35.663613,
139.73229</Coordinates>
		</Geometry>
		<Property>
					<WeatherAreaCode />
			<WeatherList>
				<Weather>
					<Type>observation</Type>
					<Date>201909111545</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111555</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111605</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111615</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111625</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111635</Date>
					<Rainfall />
				</Weather>
				<Weather>
					<Type>forecast</Type>
					<Date>201909111645</Date>
					<Rainfall />
				</Weather>
			</WeatherList>
		</Property>
	</Feature>
</YDF>

JSON

{
  "?xml": {
    "@version": "1.0",
    "@encoding": "UTF-8"
  },
  "YDF": {
    "@xmlns": "http://olp.yahooapis.jp/ydf/1.0",
    "@firstResultPosition": "1",
    "@totalResultsAvailable": "1",
    "@totalResultsReturned": "1",
    "ResultInfo": {
      "Count": "1",
      "Total": "1",
      "Start": "1",
      "Status": "200",
      "Latency": "0.006577",
      "Description": "",
      "Copyright": "(C) Yahoo Japan Corporation."
    },
    "Feature": {
      "Id": "201909111545_35.663613_139.73229",
      "Name": "地点(35.663613,\n139.73229)の2019年09月11日 15時45分から60分間の天気情報",
      "Geometry": {
        "Type": "point",
        "Coordinates": "35.663613,\n139.73229"
      },
      "Property": {
        "WeatherAreaCode": null,
        "WeatherList": {
          "Weather": [
            {
              "Type": "observation",
              "Date": "201909111545",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111555",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111605",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111615",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111625",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111635",
              "Rainfall": null
            },
            {
              "Type": "forecast",
              "Date": "201909111645",
              "Rainfall": null
            }
          ]
        }
      }
    }
  }
}

[Salesforce]Visualforceページのinputfileとactionfunction

Visualforceページのinputfileとactionfunctionを同一Visualforcrページにて使用するときにポイント。

Visualforceページのinputfileとactionfunctionを同一Visualforceページで使う時に、以下のエラー発生する場合がある。

apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.

このエラーの解決策の一つとして、actionfunctionをactionregionで囲むことです。

例えば、以下の例です。

	<apex:actionRegion >
		<apex:outputPanel id="thePanel">
			<apex:actionFunction name="theActfunc" action="{!theCtlfunc}" rerender="thePanel">
    			<apex:param name="theActprm" value="" />
			</apex:actionFunction>
		</apex:outputPanel>
	</apex:actionRegion >