// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

 * Request testnet LINK and ETH here: https://faucets.chain.link/
 * Find information on LINK Token Contracts and get the latest ETH and LINK faucets here: https://docs.chain.link/docs/link-token-contracts/

contract APIConsumer is ChainlinkClient {
    using Chainlink for Chainlink.Request;
    bytes32 public fire;
    address private oracle;
    bytes32 private jobId;
    uint256 private fee;
     * Network: Kovan
     * Oracle: 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8 (Chainlink Devrel   
     * Node)
     * Job ID: d5270d1c311941d0b08bead21fea7747
     * Fee: 0.1 LINK
    constructor() {
        oracle = 0x270C24d79A8c334240b3449B8431DaCA1972F438;
        jobId = "c307f6770b6c4ef6b2b168b396f1f9fa";
        fee = 0.1 * 10 ** 18; // (Varies by network and job)
     * Create a Chainlink request to retrieve API response, find the target
     * data, then multiply by 1000000000000000000 (to remove decimal places from data).
    function requestFireData() public returns (bytes32 requestId) 
        Chainlink.Request memory request = buildChainlinkRequest("c307f6770b6c4ef6b2b168b396f1f9fa", address(this), this.fulfill.selector);
        // Set the URL to perform the GET request on
        request.add("get", "https://ljiigsoedk.execute-api.ca-central-1.amazonaws.com/default/wildfire");
        // Set the path to find the desired data in the API response, where the response format is:
        // {"RAW":
        //   {"ETH":
        //    {"USD":
        //     {
        //      "VOLUME24HOUR": xxx.xxx,
        //     }
        //    }
        //   }
        //  }
        request.add("path", "FIRE_NUMBE");
        // Multiply the result by 1000000000000000000 to remove decimals
        //int timesAmount = 10**18;
        //request.addInt("times", timesAmount);
        // Sends the request
        return sendChainlinkRequestTo(address(0x270C24d79A8c334240b3449B8431DaCA1972F438), request, 1000000000000000000);
     * Receive the response in the form of uint256
    function fulfill(bytes32 _requestId, bytes32 _fire) public recordChainlinkFulfillment(_requestId)
        fire = _fire;

    // function withdrawLink() external {} - Implement a withdraw function to avoid locking your LINK in the contract

trying to make http call but getting error. it is calling my node to run the job though.

  "name": "",
  "initiators": [
      "id": 3,
      "jobSpecId": "c307f677-0b6c-4ef6-b2b1-68b396f1f9fa",
      "type": "runlog",
      "params": {
        "address": "0x270c24d79a8c334240b3449b8431daca1972f438"
  "tasks": [
      "jobSpecId": "c307f6770b6c4ef6b2b168b396f1f9fa",
      "type": "httpget"
      "jobSpecId": "c307f6770b6c4ef6b2b168b396f1f9fa",
      "type": "jsonparse"
      "jobSpecId": "c307f6770b6c4ef6b2b168b396f1f9fa",
      "type": "ethbytes32"
      "jobSpecId": "c307f6770b6c4ef6b2b168b396f1f9fa",
      "type": "ethtx"
  • Can you include the code where you are making the call?
    – Julissa DC
    Nov 19 at 14:19
  • the contract is deployed in remix and requestFireData function makes the call. Nov 19 at 23:57
  • Did you end up solving this? I can't tell from your answer. Nov 20 at 15:44
  • not yet, the only plausible reason for it to go 500 (internal server error) at this point of the investigation is that it does not get its parameters. Nov 21 at 10:41
  • it works from postman if given parameters in the correct format, so by deduction that if it does not return anything, it's because it wasn't when called from solidity. you'll also get 500 if you just remove parameters from postman.... so its the way from the contract to the job theres something wrong Nov 21 at 10:45

changed it to request.add("farm", "-123.95908355712889, 53.25042550620077"); FIRE_NUMBE is a list of fires, so it fails trying to make the request added a bridge with the api url, which is now used in a new job, so that everything sent using req.add ends up in the body of the request

now need to make requestFireData() accept a set of coordinates, that would then be included in the request

**fixed **had to edit the lambda to accept string, not array, and the 0.10.15 node expecting another format than we send to it from the adapter. needed to format the output from the api

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 20 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.