HDR image background


I am trying to set HDR image background for my scene.
I am expecting a colorful forest as my background but I am getting full white background.
The below is my code. I tried setting the HDR image in blender and did debugging the blender sync code to check how the shaders are populated. I did exactly the same how blender is doing but could not understand what went wrong.

Can you please throw some light?

Thanks in advance.

void set_image_background(Scene& scene)
  Background *background = scene.background;
  background->ao_factor = 1;
  background->ao_distance = 10;
  background->use_shader = true;
  background->use_ao = false;
  background->visibility = 4125;
  background->transparent = false;

  background->transparent_glass = false;
  background->transparent_roughness_threshold = 0;
  background->need_update = true;

void populate_background_shader(Shader &shader, const std::string &hdr_image_path)
  ShaderGraph *graph = new ShaderGraph();
  EnvironmentTextureNode *environment_texture_node = new EnvironmentTextureNode();
  environment_texture_node->builtin_data = nullptr;
  environment_texture_node->filename = hdr_image_path;
  environment_texture_node->colorspace = ustring("Linear");
  environment_texture_node->animated = false;
  environment_texture_node->alpha_type = ImageAlphaType::IMAGE_ALPHA_ASSOCIATED;
  environment_texture_node->interpolation = InterpolationType::INTERPOLATION_LINEAR;
  environment_texture_node->projection =
  environment_texture_node->bump = ShaderBump::SHADER_BUMP_NONE;

  BackgroundNode *background_node = new BackgroundNode();
  background_node->color = make_float3(0.0508760884);
  background_node->strength = 1;
  background_node->surface_mix_weight = 1;

  OutputNode *output_node = graph->output();

  graph->connect(environment_texture_node->output("Color"), background_node->input("Color"));
  graph->connect(background_node->output("Background"), output_node->input("Surface"));

  shader.graph = graph;
  shader.has_surface = true;
  shader.use_mis = true;
  shader.use_transparent_shadow = true;
  shader.heterogeneous_volume = true;
  shader.need_update = true;
  shader.has_surface = true;
  shader.has_surface_emission = false;
  shader.has_surface_transparent = false;

It is working actually but my model is shown in the sky. that is why white sky is shown. Need to adjust